1 using System;
2 using System.Collections.Generic;
3 using System.IO;
4 using System.Linq;
5 using System.Text;
6 using System.Threading.Tasks;
7
8 namespace _05StreamReador和StreamWrite
9 {
10 class Program
11 {
12 static void Main(string[] args)
13 {
14 //using (StreamReader sr = new StreamReader(@"C:\Users\Administrator\Desktop\1.txt", Encoding.Default))
15 //{
16 // //string i = sr.ReadLine();//只读取了一行
17 // //Console.WriteLine(i);
18
19 // //string s = sr.ReadToEnd();//从头读到尾巴
20 // //Console.WriteLine(s);
21
22 // while (!sr.EndOfStream)//判断是否读取完
23 // {
24 // string st = sr.ReadLine();
25 // Console.WriteLine(st);
26 // }
27 //}
28
29 using (StreamWriter sw = new StreamWriter(@"C:\Users\Administrator\Desktop\1.txt", true, Encoding.UTF8))
30 {
31 sw.WriteLine("嘎哈人口");
32 }
33 }
34 }
35 }
![](https://img2018.cnblogs.com/blog/1485789/201809/1485789-20180919185323721-182525183.jpg)