我有一个程序,它读取一个文本文件并将其处理为分段。C#如何使用流读取器读取文本文件时跳过行数?
所以问题是如何更改程序以允许程序在使用流读取器读取文件时跳过读取文件的前5行?
有人请告知代码吗?谢谢!
的代码:
class Program
{
static void Main(string[] args)
{
TextReader tr = new StreamReader(@"C:\Test\new.txt");
String SplitBy = "----------------------------------------";
// Skip first 5 lines of the text file?
String fullLog = tr.ReadToEnd();
String[] sections = fullLog.Split(new string[] { SplitBy }, StringSplitOptions.None);
//String[] lines = sections.Skip(5).ToArray();
foreach (String r in sections)
{
Console.WriteLine(r);
Console.WriteLine("============================================================");
}
}
}
所以最新的问题与使用注释掉行? – 2010-12-11 18:54:08
它向专家表明.split方法不起作用。 – JavaNoob 2010-12-11 19:00:38
[C#如何在文本转换为数组之后在文本文件中跳过行的可能的重复?](http://stackoverflow.com/questions/4417916/c-how-to-skip-lines-in-text-file-after -text-coverted-array) – ChrisF 2010-12-11 19:01:23