求助!!!做打开文件时遇到的问题!小弟先谢谢了!!!
小弟刚刚开始学习c#,代码如下:private void toolStripOpen_Click(object sender, EventArgs e)
{
openFileDialog1.Title="我的文档";
openFileDialog1.InitialDirectory = @"c:\";
string filter="文本文档(*.txt)|*.txt";
openFileDialog1.Filter = filter;
openFileDialog1.Multiselect = false;
if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
{
return;
}
else
{
frmEdit frm = new frmEdit();
frm.MdiParent = this;
frm.Text=openFileDialog1.FileName;
StreamReader sr = new StreamReader(openFileDialog1.OpenFile());
RichTextBox richTextBox1 = new RichTextBox();
richTextBox1.Text = sr.ReadToEnd();
frm.Show();
}
}
运行后读不出所要打开文件的内容!求哪位高手帮忙解答一下!!!!谢谢了 !!