Public void download (string path)
{
Try
{
String filepath = path;
Int temp = filepath. lastindexof ("/") + 1;
String filename = filepath. substring (temp, filepath. Length-Temp );
// Filestream = new filestream (server. mappath (filepath), filemode. Open, fileaccess. Read, fileshare. Read );
Filestream = new filestream (filepath, filemode. Open, fileaccess. Read, fileshare. Read );
Long filesize = filestream. length;
Context. response. contenttype = "application/octet-stream ";
Context. response. addheader ("content-disposition", "attachment; filename = \" "+ httputility. urlencode (filename, system. text. encoding. utf8) + "\"");
Context. response. addheader ("Content-Length", filesize. tostring ());
Byte [] filebuffer = new byte [filesize];
Filestream. Read (filebuffer, 0, (INT) filesize );
Filestream. Close ();
Context. response. binarywrite (filebuffer );
Context. response. End ();
}
Catch
{
Response. Write ("<SCRIPT> alert ('check this information or deleted '); </SCRIPT> ");
}
}