回复 楼主 shiyongjian
对了,我写的代码:
private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog Open = new OpenFileDialog();
Open.Filter = "(*.txt)|*.txt|(*.*)|*.*";
Open.FilterIndex = 1;
if (Open.ShowDialog() != DialogResult.OK)
return;
try
{
StreamReader sw = new StreamReader(Open.FileName, true);
string a = sw.ReadLine();
while (sw.ReadLine() != null)
{
richTextBox1.Text +=a;
richTextBox1.Text += "\r\n";
a = sw.ReadLine();
}
sw.Close();
}
catch(IOException ex)
{
MessageBox.Show(ex.Message);
return;
}
}