[C#] C#控制台进行文件读写的简单范例 →→→→→进入此内容的聊天室

来自 , 2020-04-05, 写在 C#, 查看 159 次.
URL http://www.code666.cn/view/c622c085
  1. using System;
  2. using System.IO;
  3. class file1 {
  4.     public static void Main()
  5.     {
  6.        string PATH = null;
  7.        Console.WriteLine("file path: ");//这里输入文本所在目录 例如 d:\text.txt
  8.        PATH = Console.ReadLine();
  9.        StreamWriter sw = new StreamWriter(PATH);
  10.        string str = null;
  11.        while(true){
  12.            str = Console.ReadLine();
  13.            if (str == "end") {
  14.                break;
  15.            }
  16.            sw.WriteLine(str);
  17.        }
  18.        sw.Close();  
  19.        Console.ReadKey();
  20.     }
  21. }
  22.  
  23.  
  24. //csharp/6484

回复 "C#控制台进行文件读写的简单范例"

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

captcha