我在文本中有这个文件,需要在表格中组织排序。 OBS:需要是控制台应用程序c#
我这样做了:
StreamReader sr = new StreamReader(@"filepatch.txt");
string ler = sr.ReadLine();
string linha = ";";
int cont = 0;
while((linha = sr.ReadLine())!= null)
{
string col = linha.Split(';')[2];
cont++;
Console.WriteLine("{0} : {1}", cont, linha);
}
试试这个来获取文件文本:
var lines = System.IO.File.ReadAllLines(@"filepatch.txt");
然后你可以使用返回的string[]
来执行其余的逻辑。
foreach(var line in lines)
{
string[] cols = line.Split(';');
// Your logic here.
}
干杯!