// Output hard disk files, provide download
// Enter the parameter _Request: Page.Request object, _Response: page.response object, _filename: Download file name, _fullpath: with file name download path, _speed Allow the number of bytes per second
// Return to whether it is successful
public static bool ResponseFile (HttpRequest _Request, HttpResponse _Response, string _fileName, string _fullPath, long _speed) {try {FileStream myFile = new FileStream (_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); BinaryReader br = new BinaryReader ( Myfile; "accect-ranges", "bytes"); _RESPONSE.BUFFER = false; long filength = myfile.length; long startbytes = 0; int Pack = 10240; // 10K bytes // INT Sleep = 200; // 5 times per second 5 * 10K bytes per second INT SLEP = (int) math.floor (1000 * pack / _speed) 1; if (_Request.Headers ["Range"]! = null) {_RESPONSE.STATUSCODE = 206; string [] Range = _Request.Headers ["Range"]. Split (new char [] {'=', '-'}); startBytes = Convert.Toint64 (Range [1]); } _Response.addheader ("Content-length", ("Content-length" .tostring ()); if (StartBytes! = 0) {_RESPONSE.ADDHEADER ("Content-Range", string.format ("bytes {0} - {1} / {2}, startbytes , FileLength-1, FileLength);} _Response.addheader ("Connection", "Keep-alive"); _RESPONSE.CONTENTTYPE = "Application / OCTET-stream"; _Response.addheader ("Content-Disposition", "Attachment; filename = " HttpUtility.UrlEncode (_fileName, System.Text.Encoding.UTF8)); br.BaseStream.Seek (startBytes, SeekOrigin.Begin); int maxCount = (int) Math.Floor ((fileLength - startBytes) / pack ) 1;
For (int i = 0; i