• 读取文本,不能全部读出来?
  • 其它
    1.00元

private void button2_Click(object sender, EventArgs e)
{
string filePath = "";
OpenFileDialog opd = new OpenFileDialog();
if (opd.ShowDialog() == DialogResult.OK)
{
filePath = opd.FileName;
}
StreamReader sr = new StreamReader(filePath,Encoding.Default);
string s = sr.ReadLine();
while (sr.ReadLine()!=null)
{
textBox1.Text+=s + "\r\n";
s = sr.ReadLine();
}
}
创建一个10行的文本,为什么只能读出来奇数行?无法全部读出来,怎么解决?

  • 西西    2020-07-01 16:20:05
  • 阅读 1126    收藏 0    回答 1
  • 邀请
  • 收藏
  • 分享
发送
登录 后发表评论
  • 51testing软件测试圈微信