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

来自 , 2019-03-17, 写在 C#, 查看 142 次.
URL http://www.code666.cn/view/f1676935
  1.  
  2. using System;
  3. using System.IO;
  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.  
  25. //csharp/4113

回复 "C#读写文本文件代码片段"

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

captcha