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!

Writing to a file (.dat)

Status
Not open for further replies.

ri

Programmer
Nov 2, 2000
12
0
0
GB
I have the following code to write a filename (which is passed from elsewhere) to the top line (I guess by making a new line) of a dat file leaving the rest of its contents untouched. This code puts the filename there but seems just to be making a new file as the contents of the original file dissapear.

Function WriteLineToFile(filename)
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile(DATA_PATH & filename, ForWriting, False)
f.WriteLine filename
End Function

Can you help?
 
Ri,

You are opening for writing - you should open for
Read AND Write if you wish to conserve the contents of the file. I have not checked but I guess it is 3...

Regards,
Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top