write to text file

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?
 
H

Herfried K. Wagner [MVP]

* "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.
 
M

Marc Butenko

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,
 
C

Cor Ligthert

Hi Herfried,

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

I am very curious about that?

Cor
 
H

Herfried K. Wagner [MVP]

* "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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top