简体   繁体   English

从绝对路径显示pdf文件

[英]Display pdf file from absolute path

I am using this code for creating pdf viewer in my application https://amitpatriwala.wordpress.com/2009/08/28/pdf-viewer-in-asp-net/ 我正在使用此代码在我的应用程序中创建pdf查看器https://amitpatriwala.wordpress.com/2009/08/28/pdf-viewer-in-asp-net/

it works fine when I give it a path for a file inside my application folders, ex: displaypdf1.FilePath= @"~/MyFolder/" + Hello.pdf; 当我在应用程序文件夹中为其提供文件路径时,它可以正常工作,例如: displaypdf1.FilePath= @"~/MyFolder/" + Hello.pdf;

but now I want to give this displaypdf1.FilePath an absolute path to read the pdf file which is not in my application folders, I tried but it didn't work! 但是现在我想给这个displaypdf1.FilePath一个绝对路径,以读取不在我的应用程序文件夹中的pdf文件,我尝试了但是没有用!

A web page cannot access items that are outside of the website. 网页无法访问网站之外的项目。 If you want the web page to reference files located in D:\\PDFs , for example, you need to create a virtual directory in your website that points to "D:\\PDFs". 例如,如果您希望网页引用位于D:\\PDFs文件,则需要在网站中创建一个指向“ D:\\ PDFs”的虚拟目录。 Then the web pages can access them by ~/PDFs/Hello.pdf. 然后网页可以通过〜/ PDFs / Hello.pdf访问它们。

You'll also need to ensure that the website has appropriate permissions to access the directory. 您还需要确保网站具有访问目录的适当权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM