Writeline to textfile?

hbrems

has no clue...
Local time
Today, 05:44
Joined
Nov 2, 2006
Messages
181
Isn't writeline supposed to start a new line when you write data to a textfile?

Set fs = CreateObject("Scripting.FileSystemObject")
Set vtextfile = fs.CreateTextFile("c:\testfile.txt", True)
vtextfile.write ("test")
vtextfile.Close

This code replaces what's already in the file with new data.
 
The Write or WriteLine method of the textstreamobject should do that. What is causing the challenge here, is probably that you aren't opening an existing textfile, you are creating a new one. Try something like the following

if fs.fileexists("c:\testfile.txt") then
Set vtextfile = fs.OpenTextFile("c:\testfile.txt", 3) ' 3 = ForAppending
else
Set vtextfile = fs.CreateTextFile("c:\testfile.txt", True)
end if
vtextfile.write "test"
 

Users who are viewing this thread

Back
Top Bottom