一行的方法就够了:
private static IEnumerable
{
return File.ReadAllLines(path.ToString()).ToList().Skip(start).Take(count);
}
参数说明:
path:txt文件路径
start:开始行数,默认从第0行开始(即首行)
count:读入行数,默认全部读入
只有手机,帮你手打先试试,不行追问我再帮改
Public string ReadLineAt(int lineNumber, string path)
{
FileInfo fi=new FileInfo(path);
if(!fi.exist) return "文件不存在";
FileStream fs=new FileStream(path, FileMode.Open);
StreamReader sr=new StreamReader(fs);
for(int i=0;i
if(fs.EndOfStream)
return "超出文本区域";
sr.ReadLine();
}
if(fs.EndOfStream)
return "超出文本区域";
return sr.ReadLine();
}