c# 读取文件,一次可以读取多少个字节数组,我有一个文件,内容差不多是1000万个字节,该怎么读????
2个回答
展开全部
string sFilePath=@"D:\\Test\\datfil.txt";
FileStream fileStream = new FileStream(sFilePath, FileMode.Open, System.IO.FileAccess.Read);
byte[] byteRecord = new byte[1000];
long lSize = fileStream.Length;
long lReadTimes = lSize /1000;
int iTemp = lSize %1000;
fileStream.Seek(0, SeekOrigin.Begin);
for (int i = 1; i <= lReadTimes ; i++)
{
fileStream.Read(byteRecord, 0, 1000);
}
fileStream.Read(byteRecord, 0, iTemp );
FileStream fileStream = new FileStream(sFilePath, FileMode.Open, System.IO.FileAccess.Read);
byte[] byteRecord = new byte[1000];
long lSize = fileStream.Length;
long lReadTimes = lSize /1000;
int iTemp = lSize %1000;
fileStream.Seek(0, SeekOrigin.Begin);
for (int i = 1; i <= lReadTimes ; i++)
{
fileStream.Read(byteRecord, 0, 1000);
}
fileStream.Read(byteRecord, 0, iTemp );
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询