using System.IO;
class Program
{
static void Main(string[] args)
{
//循环读取大文本文件
FileStream fsRead;
//获取文件路径
string filePath="C:\\Users\\国兴\\Desktop\\1号店账号.txt";
//用FileStream文件流打开文件
try
{
fsRead = new FileStream(@filePath,FileMode.Open);
}
catch (Exception)
{
throw;
}
//还没有读取的文件内容长度
long leftLength = fsRead.Length;
//创建接收文件内容的字节数组
byte[] buffer = new byte[1024];
//每次读取的最大字节数
int maxLength=buffer.Length;
//每次实际返回的字节数长度
int num=0;
//文件开始读取的位置
int fileStart=0;
while (leftLength>0)
{
//设置文件流的读取位置
fsRead.Position=fileStart;
if (leftLength<maxLength)
{
num=fsRead.Read(buffer,0,Convert.ToInt32(leftLength));
}
else{
num=fsRead.Read(buffer,0,maxLength);
}
if (num==0)
{
break;
}
fileStart += num;
leftLength -= num;
Console.WriteLine(Encoding.Default.GetString(buffer));
}
Console.WriteLine("end of line");
fsRead.Close();
Console.ReadKey();
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有