using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace A07_IOTextFileReadAndWrite
{
class Demo9
{
private string _StrPath = @"E:\test.txt";
//文本文件的写入
public void Test1()
{
string str = "Hello everyone!";
StreamWriter sw = new StreamWriter(_StrPath);
sw.WriteLine(str);
sw.Close();
}
//文本文件的读取
public void Test2()
{
StreamReader sr = new StreamReader(_StrPath);
while (sr.Peek()>=0)
{
Console.WriteLine(sr.ReadLine());
}
sr.Close();
}
static void Main(string[] args)
{
Demo9 obj = new Demo9();
//obj.Test1();
obj.Test2();
}
}
}