private void DownloadFile(String strFileName){FileStream fs;
string strContentType;string strPath=TaskManagementTool.Config.Path.ToString();
//Dim strFileName As String = Request.QueryString(”DocumentFile”)fs = File.Open(Server.MapPath(strPath + strFileName), FileMode.Open);
Byte[] bytBytes = new byte[fs.Length] ; // Write the stream to the byte array
fs.Read(bytBytes, 0, Convert.ToInt32(fs.Length)); // Close the file stream to release the resource
fs.Close();Response.AddHeader(“Content-disposition”, “attachment; filename=”+strFileName);
// Next we need to add some header information.// These headers will tell the browser what it needs to do
// with the content we’re serving
Response.ContentType = “application/octet-stream”;// Now our headers are added, we can serve the content.// To do this, we use the BinaryWrite() method of the server object
// This successfully streams our external file to the user,
// despite the fact that the file doesn’t exist
// anywhere inside the web application
Response.BinaryWrite(bytBytes);// Call Response.End() so that no more// content goes through to the client.
Response.End();}
}