110,499
社区成员
发帖
与我相关
我的任务
分享
//方法1
//按行读文件,跳过行
StreamReader reader = File.OpenText("文件");
int skip = 3;//假设跳过3行从第四行开始
string line = reader.ReadLine();
int current_line = 1;
while (line != null && current_line++ < skip)
{
line = reader.ReadLine();
}
//读取剩下所有行
List<string> lines = new List<string>();
while (line != null)
{
lines.Add(line);
line = reader.ReadLine();
}
//lines就是你要的
//方法2
//或是Linq写法
string[] lines_array = File.ReadAllLines("文件").Skip(3).ToArray();