临泽县张辉:请教大虾们,C#.Net中如何打开文本文件并将其识别为字符串?

来源:百度文库 编辑:神马品牌网 时间:2024/05/07 18:39:30
我要应用文本中的数据,如何打开并使其转换成可识别的字符串形式??
不胜感激

FileStream fs=new FileStream("e:\test.txt",FileMode.Open,FileAccess.Read);
StreamReader sw=new StreamReader(fs,System.Text.Encoding.GetEncoding("GB2312"));
sw.BaseStream.Seek(0,SeekOrigin.Begin);
string line=sw.ReadLine();
while(line!=null)
{
this.TextBox3.Text+=line+"\n";
line=sw.ReadLine();
}
sw.Close();