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

转载于:https://www.cnblogs.com/wlq2000/archive/2005/04/17/139254.html

你可能感兴趣的:(java,c#)