C#如何读取txt文件中每一行每一个数据

2024-11-30 17:33:33
推荐回答(2个)
回答1:

string path1 = "路径";
using(StreamReader sr = new StreamReader(path,Encoding.Default))
{
String line;
while ((line = sr.ReadLine()) != null)
{
string[] nums=line.spilte(new char[]{','},StringSplitOptions.RemoveEmptyEntries
);
//todo
}

}

回答2:

Flie.ReadAllLines("stringpath",文字编码格式)