读文本文件出现乱码,怎么回事?
很急啊,大侠们帮改一下。OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
string fname = ofd.FileName;
StreamReader sr = new StreamReader(fname, UnicodeEncoding.GetEncoding("gb2312"));
//开始读取
string read;
while ((read = sr.ReadLine()) != null)
{
sr = new StreamReader(ofd.FileName, System.Text.Encoding.Unicode);
textBox1.Text = sr.ReadToEnd();
//要执行的操作
}
}