我目前正在打开一个文件并将其显示在消息框上。
private void button2_Click_1(object sender, EventArgs e)
{
//OpenFileDialog1.ShowDialog();
OpenFileDialog file = new OpenFileDialog();
file.FileName = "";
file.Title = "Open A Text document.";
file.Filter = "(*.gc)|*.gc|(*.etf)|*.etf|(*.txt)|*.txt|(*.GC)|*.GC|(*.tap)|*.tap";
DialogResult result = file.ShowDialog();
if (result == DialogResult.OK)
{
System.IO.StreamReader OpenFile = new System.IO.StreamReader(file.FileName);
textBox1.Text = OpenFile.ReadToEnd();
OpenFile.Close();
}
if (file.FileName.Length > 0)
{
OpenFile(file.FileName);
}
但我需要逐行读取文件并将其显示在消息框上。有没有办法更改此代码。