这个问题其实很简单。看代码:
StreamReader sr = new StreamReader("c:\\a.txt");
while (sr.Read())
{
string str = sr.ReadLine();
//这里处理 str
}
这样子,是读一行处理一行.明白吗?
static void Main(string[] args)
{
string strPath = txt的位置
string line = string.Empty;
StreamReader sr = new StreamReader(strPath);
line = sr.ReadLine();
}
读到的line就是一行,你可以分割出来
你可以通过循环来读
while(( line = sr.ReadLine()) != null)...