using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StreamReader和StreamWriter
{
class Program
{
static void Main(string[] args)
{
//StreamReader和StreamWriter只能操作字符,不能操作字节
using (StreamReader sr = new StreamReader(@"1.txt", Encoding.Default))
{
while (!sr.EndOfStream)
{
Console.WriteLine(sr.ReadLine());
}
}
using (StreamWriter sw = new StreamWriter(@"1.txt", true, Encoding.Default))
{
sw.WriteLine("今天天气真好!" + DateTime.Today);
}
}
}
}
StreamReader和StreamWriter用法
最新推荐文章于 2025-05-23 13:56:32 发布