writing a string to specific line

windowsdevelop

New member
Joined
Nov 17, 2006
Messages
4
Programming Experience
Beginner
Say i had in a text file
steven
alice

I want to be able to write "sophie" on the second line but whats was there get pushed down a line hence u get

steven
sophie
alice
How would I do this? There's no method to write to a specific line in th IO.file class
 
One method would be to open the file ReadWrite, read every line after the wanted insertion point into a List(Of String) variable, deleting as you go. Then, write your line, followed by each line that was read previously.

I'm sure there's a better way...not comming to me right now.
 
Back
Top