ururk
New member
- Joined
- Nov 29, 2005
- Messages
- 1
- Programming Experience
- Beginner
I'm very new to Visual Basic, am working on an existing application.
Here is my code:
The file is a csv file like so:
2005-11-1T0:00:00,0
2005-11-1T1:00:00,0
2005-11-1T2:00:00,0
2005-11-1T3:00:00,0
2005-11-1T4:00:00,0
2005-11-1T5:00:00,0
2005-11-1T6:00:00,0
2005-11-1T7:00:00,0
2005-11-1T8:00:00,0
lines(0) is a timestamp formatted like above, lines(1) is a value (from 0-400)
First I open a FileStream and a StreamReader, and find the string "2005-11-1T6:00:00"
I have a counter which records which line of the file I am on.
I would like to then:
Close the StreamReader. Open a StreamWriter, go to the line I want to replace, and then replace just that line. I do not want to read the entire file in as a string, replace the string, then write the entire file back.
Any help?
Thanks!
John
Here is my code:
VB.NET:
Dim logFile2 As New FileStream("Files\2005-12.csv", FileMode.Open, FileAccess.Write)
Dim logWriter As New StreamWriter(logFile2)
logWriter.WriteLine(lines(0) & "," & lines(1))
logWriter.Flush()
logFile2.Close()
2005-11-1T0:00:00,0
2005-11-1T1:00:00,0
2005-11-1T2:00:00,0
2005-11-1T3:00:00,0
2005-11-1T4:00:00,0
2005-11-1T5:00:00,0
2005-11-1T6:00:00,0
2005-11-1T7:00:00,0
2005-11-1T8:00:00,0
lines(0) is a timestamp formatted like above, lines(1) is a value (from 0-400)
First I open a FileStream and a StreamReader, and find the string "2005-11-1T6:00:00"
I have a counter which records which line of the file I am on.
I would like to then:
Close the StreamReader. Open a StreamWriter, go to the line I want to replace, and then replace just that line. I do not want to read the entire file in as a string, replace the string, then write the entire file back.
Any help?
Thanks!
John