Download more than 100M files

xiaoxiao2021-03-06  103

///

/// Download file /// public class filedownload: system.Web.ui.page {/// /// Download file /// // / file path /// file name public static void download (string filepath, string filename) {stream istream = NULL; / / Buffer to read 10k bytes in chunk: Byte [] buffer = new byte [10000];

// Length of the file: int layth;

// Total bytes to read long datatoread;

Try {// Open the file. istream = new filestream (filepath, filemode.open, fileaccess.read, fileshare.read);

// Total Bytes to read: datatoread = istream.length;

HttpContext.Current.Response.ContentType = "application / octet-stream"; HttpContext.Current.Response.AddHeader ( "Content-Disposition", "attachment; filename =" HttpUtility.UrlEncode (FileName));

转载请注明原文地址:https://www.9cbs.com/read-122919.html

New Post(0)