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:
  1. Dim WriteFile1 As Integer
  2. Dim i As Integer
  3.  
  4. WriteFile1 = 10
  5.  
  6. Open “Data.txt” For Output As WriteFile1
  7.  
  8. For i = 0 To 9
  9.     Print #WriteFile1, [url]www.InputS1(i[/url])
  10. Next
  11.  
  12. Print #WriteFile1, “Hello World  1     4    3          5    3    5”
  13.  
  14. Print #WriteFile1, [url]www.InputS1(11[/url])
  15.  
  16. Close WriteFile1

How might this be accomplished in .NET? Thanks in advance for any help.