///
// 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));