//获取文件的路径
this.textBox3.Text=this.openFileDialog1.FileName;
//读去文件到文本筐中
try
{
if(!File.Exists(this.textBox3.Text.Trim()))
{
MessageBox.Show("wenjianbucunzai");
}
else
{
//打开文件流
FileStream fs=File.OpenRead(this.textBox3.Text.Trim());
//创建一个byte数组读取
byte[] arr=new byte[fs.Length];
UTF8Encoding datautf=new UTF8Encoding(true);
if(arr.Length>0)
{
fs.Read(arr,0,arr.Length);
this.textBox4.Text=datautf.GetString(arr);
fs.Close();
}
}
}
catch(IOException ex)
{
ex.StackTrace.ToString();
}
为什么读出来的文本是乱码?(中文是这样)