实现效果:
知识运用:
StreamReader类的ReadLine方法
实现代码:
private void button1_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); string strLine = null; open.Filter = "文本文件(*.txt)|*.txt"; open.ShowDialog(); textBox1.Text = open.FileName; StreamReader st=new StreamReader(textBox1.Text); while((strLine=st.ReadLine())!=null) { textBox2.Text += strLine + Environment.NewLine; } }