日期:2014-05-18 浏览次数:20751 次
FileStream fs = new FileStream(@"C:\text.txt",FileMode.Open,FileAccess.Read); StreamReader sr = new StreamReader(fs); try { string[] myData = sr.ReadToEnd().Split(','); } catch(Exception ex) {} finally { sr.Close(); fs.Close(); }
------解决方案--------------------
这样试下,注意下编码
using (StreamReader sr = new System.IO.StreamReader(@"d:\test.txt", System.Text.Encoding.Default)) { while (sr.Peek() > -1) { string[] list = sr.ReadLine().TrimEnd().Split(','); foreach (string s in list) { Console.WriteLine(s); } } } Console.ReadLine();