0
我有一个文本文件,我需要逐行读取。现在根据我的要求,我必须在读取文本文件后 lines.for这个我想使用跳过(),但它不工作..Here是我的代码..如何在C#中跳过指定行数后读取文本文件
string FileToCopy = "D:\\tickets.txt";
if (System.IO.File.Exists(FileToCopy) == true)
{
var fs = new FileStream(FileToCopy, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using (var reader = new StreamReader(fs))
{
string line;
string rawcdr="";
while (true)
{
while ((line = reader.ReadLine()).Skip(65) != null)
{
if (line != "")
{
rawcdr = line.ToString();
}
var strings = rawcdr.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (strings.Length != 0)
{
}
}
}
}
}
在executig上述code.Text文件从第一行读取,而我确实需要从66阅读 line ..我哪里错了?
..because'(线= reader.ReadLine())'..计算结果为一个字符串。您正在跳过65个字符。另外,'while(true)'没有中断会锁定这个.. –
@SimonWhitehead如何实现从文本文件跳过65行? – Adi