gpt4 book ai didi

C#.NET 流写入器 : How to skip lines when writing file using StreamWriter?

转载 作者:行者123 更新时间:2023-11-30 13:50:13 26 4
gpt4 key购买 nike

我使用 StreamReader 读入了一个文本文件。我想写出同一个文本文件,除了它的前 4 行和最后 6 行。

我该怎么做?谢谢。

最佳答案

string[] fileLines = File.ReadAllLines(@"your file path"); 

var result = fileLines.Skip(4).Take(fileLines.Length - (4 + 6));

File.WriteAllLines(@"your output file path", result);

关于C#.NET 流写入器 : How to skip lines when writing file using StreamWriter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7101741/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com