write to text file

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a text file that i need to write multiple lines of data to but one at
a time.
how can i write more then one line of data to the file?

example:
i do a search for a file on a server if the file does not exist on the
server i write it to text file.
then i search for another file and if that does not exist, again write to
the text file.

I need to use the same text file and add all the files that do not exist to
the file without loosing any.
how can i do that?
 
* "Mike said:
I have a text file that i need to write multiple lines of data to but one at
a time.
how can i write more then one line of data to the file?

Have a look at 'System.IO.StreamWriter' and its 'WriteLine' method.
 
I think your problem is that you need to open the file with the Append flag
set to True so the file is not overwritten everytime:

Dim IOFile as IO.StreamWriter("LogFile.txt", True)
....
IOFile.WriteLine(txtToWrite)
IOFile.Close

Hope that helps,
 
Hi Herfried,

Is there an error in the MSDN sample link I did send?

I am very curious about that?

Cor
 
* "Mike said:
i'm using the writeline method to write 1 line currently

You can call it several times, or you can call 'Write' with an already
preformatted string that includes more than one line.
 
Back
Top