Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. IO;
Public partial class downloadfiles: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
}
///
/// File Download
///
///Complete file path
Private void filedownload (string fullfilename)
{
// Set the format of the saved file (example: *. xls ):
// Response. contenttype = "application/MS-excel ";
Fileinfo downloadfile = new fileinfo (fullfilename );
Response. Clear ();
Response. clearheaders ();
Response. Buffer = false;
Response. contenttype = "application/octet-stream ";
Response. appendheader ("content-disposition", "attachment; filename =" + httputility. urlencode (downloadfile. fullname, system. Text. encoding. utf8 ));
Response. appendheader ("Content-Length", downloadfile. length. tostring ());
Response. writefile (downloadfile. fullname );
Response. Flush ();
Response. End ();
}
Protected void butdownload1_click (Object sender, eventargs E)
{
Filedownload (@ "D:/downloadfile/ .rar ");
}
Protected void butcancel_click (Object sender, eventargs E)
{
Response. Redirect ("Main. aspx ");
}
}