private void button1_Click(object sender, System.EventArgs e)
{
openFileDialog1.CheckFileExists=true;
openFileDialog1.CheckFileExists=true;
openFileDialog1.Multiselect=false;
openFileDialog1.Filter="文件类型(*.txt)|*.txt";
openFileDialog1.Title="请选择一个txt格式文件";
openFileDialog1.InitialDirectory="C";
openFileDialog1.ShowReadOnly=true;
openFileDialog1.ShowHelp=true;
if ((this.openFileDialog1.ShowDialog()==DialogResult.OK)&
(openFileDialog1.FileName.Length>0))
{
this.richTextBox1.LoadFile(this.openFileDialog1.FileName,
RichTextBoxStreamType.PlainText);
//catch{}
}
if (this.openFileDialog1.ReadOnlyChecked==true)
{
this.richTextBox1.ReadOnly=true;
}
else
{this.richTextBox1.ReadOnly=false;}
}