I have written code for file upload / download .It is working fine but when using download manager(DAP) then instead of file ,.aspx file is being download itself.
please suggest me.
For uploading I used code as:
//fupload is asp:FileUpload control
fupload.SaveAs(Server.MapPath("./Image1/Image1/"+fupload.FileName));
and for downloading :
//fName is string that holds file name for downloading
System.IO.FileInfo fileToDownload = new System.IO.FileInfo(Server.MapPath("Image1/Image1/"+fName));
if (fileToDownload.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileToDownload.Name);
//Response.AddHeader("Content-Length", fileToDownload.Length.ToString());
Response.ContentType = "application/OCTET-STREAM";
//Response.Flush();
Response.WriteFile(fileToDownload.FullName);
Response.End();
}
Loading
Vijay YadavPosted Jan 18, 2011, 6:28 AM
To download the file
//string strFilePath = "D:\\FolderName\File1.doc"
//HttpContext.Current.Response.ContentType = "application/octet-stream";
//HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(strFilePath));
//HttpContext.Current.Response.Clear();
//HttpContext.Current.Response.WriteFile(strFilePath);
//HttpContext.Current.Response.End();
I hope it will help you
In case of any query let me know
Thanks
Vijay