using System.IO;
if(openFileDialog.ShowDialog() == DialogResult.OK)
{
StreamReader sr = File.OpenText(openFileDialog.FileName);
textBox1.Text = sr.ReadToEnd();
sr.Close();
}
if(openFileDialog.ShowDialog() == DialogResult.OK)
{
StreamReader sr = File.OpenText(openFileDialog.FileName);
textBox1.Text = sr.ReadToEnd();
sr.Close();
}
解决方案 »
- C# winform 如何在子窗体中让窗体Treeview加载节点
- C# Response.Redirect传值给另一个页面时出错 在线求解
- 如何让方向键的移动,让焦点不在控件上(如按钮上)移动
- C#海康流媒体客户端开发--非常棘手
- 局域网聊天程序如何实现类似QQ的文本与图片混合传送?
- 关于方法参数的传递问题
- Convert.ToString(dr["oi_VNO"])与(string)dr["oi_VNO"])的区别?
- WinForm开发性能问题
- VS2005, MDI主窗口不能关闭,救急!!
- 各位大虾!请帮帮我!
- 招聘.NET高级软件工程师及系统分析师
- 那位大哥大姐小弟小妹给我一份会议记录?
using System.Text代码中:
Encoding en;
StreamReader sr = new StreamReader(
openFileDialog.FileName,
en.GetEncoding("GB18030"));或者是gb2312
StreamReader sr = new StreamReader(openFileDialog1.FileName,en.GetEncoding("GB18030"));
textBox2.Text = sr.ReadToEnd();
sr.Close();
编译有错误。
说明GetEncoding为静态的不能实例化用Encoding.GetEncoding即可