C# 中 filestream的fs.Read方法,怎么把文本中的数据每一行作为一个元素读到数组中。

直接fs.Read(data,0,data.length);的话会把里面所有的数据直接读出来,,不会分行的。。。这个要怎么处理。而且还是二进制的。。我去。。

System.IO.FileStream fs = new System.IO.FileStream("C:\\test.txt", System.IO.FileMode.Open);
byte[] bContent = new byte[fs.Length];
fs.Read(bContent, 0, bContent.Length);
string txt = System.Text.Encoding.Default.GetString(bContent); //获取文本
fs.Close();
fs.Dispose();
string[] txtLine= txt.split('\n'); //分行给数组
温馨提示:答案为网友推荐,仅供参考
相似回答