Click here to Skip to main content
15,888,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
[no name] 18-May-13 7:16am    
You write a SELECT query and get the URL back out of the database.
[no name] 18-May-13 7:19am    
ya,am select fileurl from database,which control is show the pdf file on web page(means read mode).

Use this code in your menthod:

C#
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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900