I'm working with a very large text file (around 70 thousand lines) and I want to remove the top line.
Clearly, loading the entire thing into memory, deleting the top line, then re-writing the whole thing again is inefficient:
var lines = File.ReadLines(accountFileLocation.Text).Skip(1);
File.WriteAllLines("output.txt", lines);
Is there any other way to do it?
Hehe .... finally I can say Jon Skeet said :)
Jon Skeet said : not really
What you did is one approach. The second will have to open a read stream and a write stream (to a different file), and read line, then write it into the write if you want it (more for a "test lines for validity, than a all but the first line).
So ... seems like you got the right answer ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With