从绝对路径显示pdf文件

时间:2015-06-01 19:01:09

标签: c# asp.net pdf pdfviewer

我正在使用此代码在我的应用程序中创建pdf查看器 https://amitpatriwala.wordpress.com/2009/08/28/pdf-viewer-in-asp-net/

当我为应用程序文件夹中的文件指定路径时,它工作正常,例如:class Contact < ActiveRecord::Base belongs_to :user after_create do |contact| contact.delay.update_fullcontact_data end def update_fullcontact_data person = FullContact.person(self.email) if person.contact_info.given_name.present? self.name = person.contact_info.given_name end if person.contact_info.family_name.present? self.last_name = person.contact_info.family_name end if person.demographics.location_general.present? self.city = person.demographics.location_general end save! ensure save! end end

但是现在我想给这个displaypdf1.FilePath= @"~/MyFolder/" + Hello.pdf;一个绝对路径来读取不在我的应用程序文件夹中的pdf文件,我试过但它没有用!

1 个答案:

答案 0 :(得分:2)

网页无法访问网站外的内容。例如,如果您希望网页引用D:\PDFs中的文件,则需要在网站中创建一个指向&#34; D:\ PDFs&#34;的虚拟目录。然后网页可以通过〜/ PDFs / Hello.pdf访问它们。

您还需要确保网站具有访问该目录的适当权限。

相关问题