reading and writing to a txt file

bjwade62

Well-known member
Joined
May 25, 2006
Messages
50
Programming Experience
3-5
I have an existing txt file that I want to open, get the text (which is a number), add 1 to the number and save/close the txt file.

Sound like filestream but I'm not sure how to use it. I've founds peices of information but nothing I can use together.

Any help out there?

Thanks,
 
VB.NET:
		Dim sr As New IO.StreamReader("C:\Temp\MyFile.txt")
		Dim i As Integer = CInt(sr.ReadLine())
		sr.Close()

		i += 1

		Dim sw As New IO.StreamWriter("C:\Temp\MyFile.txt", False)
		sw.WriteLine(i.ToString())
		sw.Close()
 
Back
Top