日期:2014-05-18  浏览次数:20945 次

怎么判断txt文件中有多少行,并分别把每行的数据读出来?
怎么判断txt文件中有多少行,并分别把每行的数据读出来?
比如aa.txt中有内容如下:
fdfd.doc
fjdfk.xml
dfj.zip


------解决方案--------------------
TextReader.ReadLine
------解决方案--------------------
能先读后判断吗,哈哈/

C# code
            string[] line=File.ReadAllLines("e:\a.txt");
            int lines = line.Length;

------解决方案--------------------
StreamReader txtReader = new StreamReader(Application.StartupPath + "\\aa.txt.txt"); 
string[] reader = new string[100]; 
for (int i = 0; i < 100; i++) 

reader[i] = txtReader.ReadLine(); 
if (reader[i] == null) 
return; 

把txt里面的内容读到一个数组中
------解决方案--------------------
探讨
能先读后判断吗,哈哈/


string[] line=File.ReadAllLines("e:\a.txt");
int lines = line.Length;