我做了个记事本 当我打开用我自己做的记事本保存的txt文件,显示正常.
但是我打开其他不是用我自己做的记事本保存的txt文件,就会出现乱码.
帮我改改 打开的代码~
private StreamReader sr;
private string BC=null;
private void menuItem10_Click(object sender, System.EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
BC = openFileDialog1.FileName;
sr = new StreamReader(BC);
textBox1.Text = sr.ReadToEnd().ToString();
sr.Close();
}
}
但是我打开其他不是用我自己做的记事本保存的txt文件,就会出现乱码.
帮我改改 打开的代码~
private StreamReader sr;
private string BC=null;
private void menuItem10_Click(object sender, System.EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
BC = openFileDialog1.FileName;
sr = new StreamReader(BC);
textBox1.Text = sr.ReadToEnd().ToString();
sr.Close();
}
}
解决方案 »
- 关于解析xml《《《《《《《
- .net 能获取登陆用户的真实姓名吗
- fmpeg的应用,将dos执行ffmpeg时的信息动态显示到textBox里面
- 微软开源dotnetduke做的网站真不错,有c#版本吗?
- 如何在assembly取得应用程序的路径
- 求救!高手进——开机锁定如何实现!
- 服务器端没有安装.net操作环境,水晶报表如何在客户端显示?是否可以安装其他程序来解决?
- 如何根据confirm的返回值,来决定是否执行一段c#的服务器端语言,急!,在线等!
- 富文本框与picture的问题 在线等
- waveOutGetVolume()API函数调用问题
- 数组中内容按重复次数排序,并去除重复数
- 新手求助!!!!
Encoding u8 = Encoding.UTF8;
Encoding u16LE = Encoding.Unicode;
Encoding u16BE = Encoding.BigEndianUnicode;
Encoding u32 = Encoding.UTF32;
sr = new StreamReader(BC,System.Text.Encoding.GetEncoding("GB18030"));
_____________________________________________________________________哈哈,过生日还不休息,跑上来抢分....
private string BC=null;
private void menuItem10_Click(object sender, System.EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
BC = openFileDialog1.FileName;
StreamReader sr= new StreamReader(@BC, System.Text.Encoding.UTF8);
textBox1.Text = sr.ReadToEnd();
sr.Close();
}
}