Hi, I've been told that to prevent that a file to be downloaded is read into the servers memory I should split the file into chunks and send them separately to the browser. I've tried the following code but it does not help (still loads the whole file into
the memory).. Any ideas? private void downloadFile(FileStream fs, string filename) {
Response.Clear();
Response.ContentType = "APPLICATION/OCTET-STREAM";
System.String disHeader = "Attachment; Filename=\"" + filename + "\"";
Response.AppendHeader("Content-Disposition", disHeader);
int blockSize = 10 * 1024;
// read the file block wise
for( long offset = 0; offset < fs.Length; offset += blockSize) {
// if we are at the end of the file, adjust block size
if( ( offset + blockSize ) > fs.Length )
blockSize = (int) (fs.Length - offset);
byte[] buffer = new byte[ blockSize ];
// read from stream
fs.Re ...
Go to the complete details ...