Look at my download method to have help you. I have been using it. private static bool DownFile (System.Web.HttpResponse Response, string fileName, string fullPath) {try {Response.ContentType = "application / octet-stream"; Response.AppendHeader ( "Content-Disposition", "attachment; filename =" Httputility.urlencode (filename, system.text.encoding.utf8) "; charset = GB2312"); system.io.filestream fs = system.io.file.openread (Fullpath); long flen = fs.length;
// Download data int size = 102400 every 100k;
/ / Specify the size of the buffer byte [] readdata = new byte [size];
/ / If each downloaded data is larger than the size of the file, change the size of the downloaded data size for the file {size = convert.toint32 (flen);
Long fpos = 0; bool isend = false;
// Read the file while ((fpos size)> flen) {size = convert.toint32 (flen-fpos); readdata = new byte [size]; iSend = true;
// Read a compressed block fs.read (ReadData, 0, size); response.binaryWrite (READDATA); fpos = size;} fs.close (); // delete the file on the server system.io.file. DELETE (FULLPATH); RETURN TRUE;} catCh {returnaf false;}}