Click here to Skip to main content
15,886,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear,

I have created a PDF file and saving to the folder inside the application path. Locally working fine, but when i moved the file to the server it wont save to the folder.

Below is the code I used to save and open it

C#
pdfRenderer.Save(Server.MapPath("~/PDF/AdahiReport.pdf"));

Process.Start(Server.MapPath("~/PDF/AdahiReport.pdf"));



and the application is in the server path C:/report and the folder is c:/report/PDF

Kindly help me

regards
Posted

You are using asp.net. If you use the Process.Start functionality all you will do is launch the server's default PDF reader ON THE SERVER. This will do nothing on the client side. Either you have mistakenly tagged your question with ASP.NET, or you have made a very basic error in understanding what happens on the server and what will be sent to the client.
 
Share this answer
 
Use the Physical Path directly, No need for using Server.MapPath("~/PDF/AdahiReport.pdf").
like this (@"C:\\PDF\\AdahiReport.pdf").

and check if the file directory is exists or not, if not exists, create one.

if(!File.Exists (@"C:\\PDF\\))
{
Directory.Create((@"C:\\PDF\\));
}
then complete your code.
 
Share this answer
 
Please verify that the application pool identity has permission to write on the folder the application is deployed i.e. C:/report. If not grant write permission and it should work fine. One more thing if you want to open the pdf file from server on client machinie, then Process.Start(Server.MapPath("~/PDF/AdahiReport.pdf")); code will not work, you need to write response.redirect ("~/PDF/AdahiReport.pdf");

Thanks
Rohit
 
Share this answer
 
v2

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