how to write back into a text file with skipping the first 2 lines

theazza

Member
Joined
May 20, 2011
Messages
23
Programming Experience
1-3
your a legend, but can you also help me with this

how to write back into a text file with skipping the first 2 lines
 
You basically need to read the data in and then write it back out again. Open a StreamReader, read the first two lines, close the StreamReader, open a StreamWriter, write out the first two lines and then write out the rest of the new content.
 
There are lots of examples of using StreamReaders and StreamWriters already out there. How about you have a go at doing it for yourself and then post back here with what you tried if it doesn't work?
 
how do u also read a text file and save the read text to a variable so it can be called later when u actually want to write it

and ur advice worked
im such a newbie
 
If you want the entire contents of a file then you can call File.ReadAllText. If you want just a single line you can create a StreamReader and call ReadLine. In both cases, a String is returned, so you can assign it to a String variable.
 
Back
Top