如何可以用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();

posted on 2005-04-17 15:08    阅读(693)  评论(0编辑  收藏  举报

导航