I read in a text file using StreamReader. I want to write out this same text file EXCEPT its first 4 lines and its last 6 lines.
How do I do this? Thanks.
string[] fileLines = File.ReadAllLines(@"your file path");
var result = fileLines.Skip(4).Take(fileLines.Length - (4 + 6));
File.WriteAllLines(@"your output file path", result);
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