using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//添加命名空间
using System.IO;
namespace 读取文本文件
{
class Program
{
static void Main(string[] args)
{
//读取
using (StreamReader sr = new StreamReader(@"C:\Users\Administrator\Desktop\电影.txt", Encoding.Default))
{
//Console.WriteLine(sr.ReadLine());
while (!sr.EndOfStream)
{
Console.WriteLine(sr.ReadLine());
}
}
//写入
//true 代表是追加文本还是覆盖文本
using (StreamWriter sw = new StreamWriter(@"C:\Users\Administrator\Desktop\newnwe.txt", true))
{
sw.Write("测试文本文段!");
}
Console.ReadKey();
}
}
}