Modifying individual lines in a text file
Hello,
This question has to do with modifying a .txt file.
I would like to choose a specific line in the text file and replace it with new text without modifying the layout of the rest of the file. In the file, there is no consistency in the number of characters per line.
VB6 code might look something like this for a file 11 lines in length where only the 10th line is changed:
VB Code:
Dim WriteFile1 As Integer Dim i As Integer WriteFile1 = 10 Open “Data.txt” For Output As WriteFile1 For i = 0 To 9 Print #WriteFile1, [url]www.InputS1(i[/url]) Next Print #WriteFile1, “Hello World 1 4 3 5 3 5” Print #WriteFile1, [url]www.InputS1(11[/url]) Close WriteFile1
How might this be accomplished in .NET? Thanks in advance for any help.




Reply With Quote