经常我们需要读一下大文件的数据文件
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(Stream fs = new FileStream(@"C: \Users\xg\Desktop\计划表.txt", FileMode.Open))
{
//定义读取数据流的大小可根据自己的需求进行调整
byte[] bytes = new byte[1024*1024];
int len;
while ((len = fs.Read(bytes, 0, bytes.Length))>0)
{
string s = Encoding.GetEncoding("utf-8").GetString(bytes,0,len);
Console.Write(s);
}
}
}
}
网友评论