我用filestream的readallbyte读取文件并输出到byte数组中,但是当读取大于1MB的文件时,数据长度就会超出数组的最大长度,请问应该怎么解决这个问题
解决方案 »
- visio 画图
- WinForm在线程中向ListView上添加ListViewItem
- 最后 40 分 大家帮忙来看看
- 安装VS2005以后,再启动以前安装的Frontpage2003,每次启动都会弹出个VS2005的窗口提示要安装什么东西,每次都要装十几分钟左右。但是如
- 这个我看不明白,是委托递归调用吗?...就是不明白怎么调用这个过程啦....
- 求DataTable中2行位置互换
- 在textbox中如何做出类似visual studio.net开发环境中智能代码补全的这种风格?
- 怎样从一个 bitmap 转换成一个 ICON,并能指定某个颜色做透明色?
- 请问如何在WinForm 的DataGrid的列中显示 一个 ComboBox 控件?
- vb如何求汉字的声母zh、ch、sh(不是求z、c、s)
- 求正则。急等
- 用SharpZipLib库如何压缩、解压缩一个目录?那位高手近来指点一下,谢谢。
Byte[] bt;
bt=File.ReadAllBytes(filepath);
int nRealRead;
do
{
nRealRead = yourFS.Read( bBuffer, 0, bBuffer.Length );
//Show data using "bBuffer );
}
while( nRealRead == bBuffer.Length );
Read 从流中读取字节块并将该数据写入给定缓冲区中。
using System;
using System.IO;class FSRead
{
public static void Main()
{
//Create a file stream from an existing file.
FileInfo fi=new FileInfo("c:\\csc.txt");
FileStream fs=fi.OpenRead();
//Read 100 bytes into an array from the specified file.
int nBytes=100;
byte[] ByteArray=new byte[nBytes];
int nBytesRead=fs.Read(ByteArray, 0, nBytes);
Console.WriteLine("{0} bytes have been read from the specified file.", nBytesRead.ToString());
}
}
byte[] buffer = new byte[(int)filestm.Length];
int iOffset = 0, iCount = buffer.Length;
while (iCount > 0)
{
int m = filestm.Read(buffer,iOffset,iCount);
if (m <= 0)
break;
iOffset += m;
iCount -= m;
}
但是当打开一个大于1MB的文件,就会提示超出了数组的范围(1000000)