Removing the first line of a text file in C#

前端 未结 5 414
眼角桃花
眼角桃花 2020-12-11 15:50

I can currently remove the last line of a text file using:

    var lines = System.IO.File.ReadAllLines(\"test.txt\");
    System.IO.File.WriteAllLines(\"test         


        
5条回答
  •  没有蜡笔的小新
    2020-12-11 16:41

    var lines = System.IO.File.ReadAllLines("test.txt");
    System.IO.File.WriteAllLines("test.txt", lines.Skip(1).ToArray());
    

    Skip eliminates the given number of elements from the beginning of the sequence. Take eliminates all but the given number of elements from the end of the sequence.

提交回复
热议问题