看看这个:PRB: Cannot Upload Large Files When You Use the HtmlInputFile Server Control Q295626 -------------------------------------------------------------------------------- The information in this article applies to:Microsoft Visual Studio .NET (2002), Professional Edition Microsoft ASP .NET (included with the .NET Framework)-------------------------------------------------------------------------------- SYMPTOMS When you try to use the HtmlInputFile control to upload a large file, the file may not be uploaded. CAUSE This problem occurs because the default value for the maxRequestLength parameter in the <httpRuntime> section of the Machine.config file is 4096 (4 megabytes). As a result, files that are larger than this value are not uploaded by default. RESOLUTION To resolve this problem, use one of the following methods:In the Machine.config file, change the maxRequestLength attribute of the <httpRuntime> configuration section to a larger value. This change affects the whole computer. In the Web.config file, override the value of maxRequestLength for the application. For example, the following entry in Web.config allows files that are less than or equal to 8 megabytes (MB) to be uploaded:<httpRuntime maxRequestLength="8192" /> MORE INFORMATION This value is restricted to 4 MB by default to restrict possible Denial of Service attacks.The maximum possible size is 2 gigabytes (GB).
这似乎是个不错的主意。不过不知道有没有其他办法呢?其实在ADO.NET里通过DataReader是可以分批读取大容量数据的。所以我想知道有没有对应的写方法。
FileStream fs;
fs=new FileStream("xxx.bmp",FileMode.Open,FileAccess.Read);
BinaryReader br;
br=new BinaryReader(fs);
int bufferSize=100;
byte[] input=new byte[bufferSize];input=br.ReadBytes(bufferSize);while(input.GetLength(0)==bufferSize)
{
//写数据
... input=br.ReadBytes(bufferSize);
}//写数据
...
Q295626
--------------------------------------------------------------------------------
The information in this article applies to:Microsoft Visual Studio .NET (2002), Professional Edition
Microsoft ASP .NET (included with the .NET Framework)--------------------------------------------------------------------------------
SYMPTOMS
When you try to use the HtmlInputFile control to upload a large file, the file may not be uploaded. CAUSE
This problem occurs because the default value for the maxRequestLength parameter in the <httpRuntime> section of the Machine.config file is 4096 (4 megabytes). As a result, files that are larger than this value are not uploaded by default. RESOLUTION
To resolve this problem, use one of the following methods:In the Machine.config file, change the maxRequestLength attribute of the <httpRuntime> configuration section to a larger value. This change affects the whole computer.
In the Web.config file, override the value of maxRequestLength for the application. For example, the following entry in Web.config allows files that are less than or equal to 8 megabytes (MB) to be uploaded:<httpRuntime maxRequestLength="8192" /> MORE INFORMATION
This value is restricted to 4 MB by default to restrict possible Denial of Service attacks.The maximum possible size is 2 gigabytes (GB).