Hi...
am stored pdf file name into folder and file url into database.
now how read(retrieving) that file from database? am struck here only.
pls help me.
解决方案Use this code in your menthod:
string strFilePath = @"\Files\test.pdf";
Response.ContentType = "jpg/doc/pdf";
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + strFilePath + "\"");
Response.TransmitFile(Server.MapPath(strFilePath));
Response.End();
Note: strFilePath is the virtual path.
Server.MapPath() will return the physical path using your specified virtual path.
Hi...
thank u for ur replay.
am also find the solution to it like.
in button event:
con = new MySqlConnection(cs);
cmd = new MySqlCommand("select * from files", con);
da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
string path = Server.MapPath("~/PDF/" + ds.Tables[0].Rows[0]["FileName"].ToString());
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(path);
if (buffer != null)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
thank u.