如何可以用openFileDialog实现打开txt文档并显示到文档中的内容
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = @"(*.txt)|*.txt";
dialog.ShowDialog();
System.IO.StreamReader sr = new StreamReader(dialog.FileName, System.Text.Encoding.Default);
string line;
while ((line = sr.ReadLine()) != null)
{
textBox1.Text += line;
}
sr.Close();