[C#] 读文件代码片断 →→→→→进入此内容的聊天室

来自 , 2020-12-21, 写在 C#, 查看 193 次.
URL http://www.code666.cn/view/d10f24cc
  1. using System;
  2. using System.IO;
  3.  
  4. public class TestReadFile
  5. {
  6. public static void Main(String[] args)
  7. {
  8. // Read text file C:\temp\test.txt
  9. FileStream fs = new FileStream(@c:\temp\test.txt , FileMode.Open, FileAccess.Read);
  10. StreamReader sr = new StreamReader(fs);
  11.  
  12. String line=sr.ReadLine();
  13. while (line!=null)
  14. {
  15. Console.WriteLine(line);
  16. line=sr.ReadLine();
  17. }
  18.  
  19. sr.Close();
  20. fs.Close();
  21. }
  22. }
  23.  
  24. //csharp/1141

回复 "读文件代码片断"

这儿你可以回复上面这条便签

captcha