Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append To Text File using FSO ???

Status
Not open for further replies.

Technos

Programmer
Mar 15, 2002
47
US
Hi there,
I'm using File System Object to append to the text file.
When we append to file it always write the text at the end of the file.
But I want to write the text at the begining of the file.
Does anybody know the solution?

Thanks,
 
I think the FSO append function will only add to the end. So how about trying this:

- Open the file using FSO.
- Read the contents of the file and assign it to a string variable, call it fileText.
- Take your newly added info, and assign it to another string variable, call it appendText.
- Then, use FSO to OVERWRITE the file with appendText & fileText.
- This way you write the new information first, then write back the previous contents of the file.
 
technos,

With fso, you will have to:

1. Read the contents of the old file
2. Open a new file with new name for write
3. Write new contents to the new file
4. Then write the contents of the old file to new file
5. Close the new file and old file

Optionally
6. Delete old file
7. Rename new file to old file


fengshui_1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top