private void 打开OToolStripButton_Click(object sender, EventArgs e)
{
OpenFileDialog openFDlg = new OpenFileDialog();
openFDlg.InitialDirectory = "C:\\";
openFDlg.Filter = "文本文件|*.txt|RTF文件|*.RTF|所有文件|*.*";
openFDlg.FilterIndex = 2;
openFDlg.RestoreDirectory = true;
if (openFDlg.ShowDialog()==DialogResult.OK)
{
string fName = openFDlg.FileName;
rtMain.LoadFile(fName);//文件格式无效
//printDocument
rtMain.Focus();
} }
为什么我打开文件时会出错显示"文件格式无效",应该处么改?注:rtMain是RichTextBox
{
OpenFileDialog openFDlg = new OpenFileDialog();
openFDlg.InitialDirectory = "C:\\";
openFDlg.Filter = "文本文件|*.txt|RTF文件|*.RTF|所有文件|*.*";
openFDlg.FilterIndex = 2;
openFDlg.RestoreDirectory = true;
if (openFDlg.ShowDialog()==DialogResult.OK)
{
string fName = openFDlg.FileName;
rtMain.LoadFile(fName);//文件格式无效
//printDocument
rtMain.Focus();
} }
为什么我打开文件时会出错显示"文件格式无效",应该处么改?注:rtMain是RichTextBox
解决方案 »
- c/s程序在服务器上跑几天就出错,用 Trace 记录到了,却也无法诊断异常,请高手给个思路!
- C# byte数组问题 16进制
- 关于progressbar的问题【涉及多线程】
- 现在我要编写军旗游戏(网络),棋盘如何去做?旗子呢都用图片实现吗?最好给个4国军旗原代码?
- 请问如何把一个pcm的音频文件用C#写一个dll转换成wav文件
- 有誰碰到這樣的錯誤?拒絕存取: 'Microsoft.Web.UI.WebControls'
- 连接地址字符过长问题
- 这个问题很幼稚,不过俺不会,还是要问
- Rundll32.exe
- NetMeeting中的“白板”如何做的?
- 动态加载WPF窗体
- 救命啊:application unavailable 2003
richTextBox1.LoadFile(fName, RichTextBoxStreamType.UnicodePlainText);
richTextBox1.LoadFile(fName, RichTextBoxStreamType.PlainText);
rtMain.LoadFile(fName,RichTextBoxStreamType.RichText); // 加载*.rtf 时用这一行