0
Answer

problem in download file

abas shahen

abas shahen

14y
2.3k
1

hi all , how r u?
i have 2 questions:
i have( Files.aspx) which contain a datalist of files names , when u click on file name , the user redirect to
new page with the fileID as the parameter of that file as follow:
DownLoadFile.aspx?FileID=112
on Page Load event of this page i have get File DaTa and File name of that file based on FileID attached with queryString
and then type this Function to Download File as follow:
private void download (DataTable dt)
{
    Byte[] bytes = (Byte[])dt.Rows[0]["Data"];
    Response.Buffer = true;
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.AddHeader("content-disposition", "attachment;filename="
    + dt.Rows[0]["Name"].ToString());
    Response.BinaryWrite(bytes);
    Response.Flush();
    Response.End();
}
but when the dialog appear ask user to open or download file , the file name appear as (DownLoadFile.aspx?FileID=112)
when u click open its show u files content in the same page , if u click download u will get error tell u cannot download DownLoadFile.aspx?FileID=112   from localhost.
 
and my final question how i can get file from Database to deal with it for some operation ( not for download) without display Download Dialog ?