-
[Solved] File question
I need to read the first line in a file then delete that line.
The only way I can think of doing this is reading in the curent file starting at the second line and then over write the file with the new data.
My question is how do I read in the file from the second line into an array to rewrite the file?
Or is there a better easyer way?
-
Re: File question
Code:
string path = //Path to the file you want to read/modify
string[] lines = System.IO.File.ReadAllLines(path);
System.IO.StreamWriter w = new System.IO.StreamWriter(path);
for(int i = 1; i < lines.length; i++)
{
w.WriteLine(lines[i]);
}
w.Close();
-
Re: File question
Thanks I knew it was easy it was late and I was not thinking the best.