Click here to Skip to main content
15,887,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to open pdf file c drive fromrticular folder.

What I have tried:

ltEmbed.Text = String.Format(embed, resolveurl(C:\erp_documents\local\Infra Management\uploaddocument\2016\7\UPLF1607200151pdf)). Can't able to open. thanks in advance.

i tried
1.server . mappath()
2.directory.fileexists
3.directory.file.openread
4.HttpContext.Current.Server.MapPath()
5.HttpContext.Current.request.MapPath
Posted
Updated 19-Jul-16 22:31pm

1 solution

Depends where the file is located: if it is on your client's PC, then you can't - security will not allow you access to it or any other part of the client hard drive. Think about it: if you could access client hard drives, so could any malicious site access yours...

If it's on your webserver, then the absolute path will work with any of the "Normal" file IO operations,provided you have the correct access permissions to the folder and file. If it's in your website folder structure, then you need to convert it to an absolute file path first using Server.MapPath:
C#
string relativePath = @"~/documents/myfile.pdf";
string absolutePath = Server.MapPath(relativePath);
 
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