Code
 1   string filePath = @Environment.CurrentDirectory + "\\SimuAppClient.txt";
 2             if(!File.Exists(filePath))
 3             {
 4                 return;
 5             }
 6             var filest = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite);
 7             using (var sr = new StreamReader(filest))
 8             {
 9                 string strLine = sr.ReadLine(); //读取文件中的一行
10                 while (strLine != null) //判断是否为空,表示到文件最后一行了
11                 {
12                     txtRead.AppendText(strLine
13                         +"\r"); //自动换行
14                     strLine = sr.ReadLine();
15                 }
16                 sr.Close(); //关闭流
17                 filest.Close();
18             }

 

相关文章:

  • 2021-11-30
  • 2021-08-16
  • 2021-07-07
  • 2021-06-01
  • 2022-01-22
  • 2021-07-24
  • 2021-09-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案