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

I have saved pdf files in ("D:\PDFFiles\test.pdf") but if i try to open
the pdf file from my asp.net application using server.transfer(filename along with path D:\PDFFiles)getting below mentioned error

System.ArgumentException: Invalid path for MapPath 'D:\PDFFiles\test.pdf'. A virtual path is expected.

please let me know how to open an pdf file which is stored in another drive

Thanks,

Vasanth
Posted

1 solution

If any client want to access any file from a web server then the file should be in the virtual directory. A client can’t access anything out side the virtual directory in the server. To implement this, you can do any of the following.


1- Store the file in the virtual directory, for example a folder in the root called “Document”, and this can be access by calling ~/Doeument/myfile.pdf.

2- If its not possible to store the file in the virtual directory and you need to store it some where else outside you virtual directory, then you can read the pdf file from the directory suing System.IO.File class and flush the content of the pdf file to the bowser.

Please note in this case in this case the default context on which your application is running should have accees to the folder where your file resides.
 
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