Public void METH1 () {/* Microsoft provides a new transmitfile method for the response object to solve the problem that the aspnet_wp.exe process cannot be successfully downloaded when the response. binarywrite file is downloaded over Mbit/s. Code As follows: */response. contenttype = "application/X-zip-compressed"; response. addheader ("content-disposition", "attachment?filename=z.zip"); string filename = server. mappath ("download/z.zip"); response. transmitfile (filename);} public void meth2 () {/* using system. io; */string filename = "asd.txt"; // the file name saved by the Client: String filepath = server. mappath ("download/" + filename); // path fileinfo = new fileinfo (filepath); response. clear (); response. clearcontent (); response. clearheaders (); response. addheader ("content-disposition", "attachment; filename =" + filename); response. addheader ("Content-Length", fileinfo. length. tostring (); response. addheader ("content-transfer-encoding", "binary"); response. contenttype = "application/octet-stream"; response. contentencoding = system. text. encoding. getencoding ("gb2312"); response. writefile (fileinfo. fullname); response. flush (); response. end () ;}public void meth3 () {string filename = "aaa.txt"; // the file name saved by the Client: String filepath = server. mappath ("download/" + filename); // path system. io. fileinfo = new system. io. fileinfo (filepath); If (fileinfo. exists = true) {const long chunksize = 102400; // 100 K read only 100 k each time, this can relieve the pressure on the server. byte [] buffer = new byte [chunksize]; response. clear (); system. io. filestream istream = system. io. file. openread (filepath); long datalengthtoread = istream. length; // get the total size of the downloaded file response. contenttype = "application/octet-stream"; response. addheader ("content-disposition", "attachment; filename =" + httputility. urlencode (filename); While (datalengthtoread> 0 & response. isclientconnected) {int lengthread = istream. read (buffer, 0, convert. toint32 (chunksize); // read size response. outputstream. write (buffer, 0, lengthread); response. flush (); datalengthtoread = datalengthtoread-lengthread;} response. close () ;}} public void meth4 () {string filename = "aaa.txt"; // string filepath = server. mappath ("download/" + filename); // path // download the file filestream FS = new filestream (filepath, filemode. open); byte [] bytes = new byte [(INT) FS. length]; FS. read (bytes, 0, bytes. length); FS. close (); response. contenttype = "application/octet-stream"; // notify the browser to download the file instead of opening response. addheader ("content-disposition", "attachment; filename =" + httputility. urlencode (filename, system. text. encoding. utf8); response. binarywrite (bytes); response. flush (); response. end ();}