如何从C盘打开文件 [英] How do I open file from C drive

查看:87
本文介绍了如何从C盘打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开pdf文件c盘fromrticular文件夹。



我尝试过:



ltEmbed.Text = String.Format(embed,resolveurl(C:\erp_documents\local \ Infra Management\uploaddocument\2016\\\\ UPLF1607200151pdf))。无法打开。提前谢谢。



我试过

1.server。 mappath()

2.directory.fileexists

3.directory.file.openread

4.HttpContext.Current.Server.MapPath()

5.HttpContext.Current.request.MapPath

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

推荐答案

取决于文件所在的位置:如果它位于客户端的PC上,则你不能 - 安全性不允许你访问它或客户端硬盘的任何其他部分。想一想:如果你可以访问客户端硬盘驱动器,那么任何恶意网站都可以访问你的...



如果它在你的网络服务器上,那么绝对路径将起作用使用任何正常文件IO操作,前提是您具有对文件夹和文件的正确访问权限。如果它在您的网站文件夹结构中,那么您需要首先使用Server.MapPath将其转换为绝对文件路径:

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:
string relativePath = @"~/documents/myfile.pdf";
string absolutePath = Server.MapPath(relativePath);


这篇关于如何从C盘打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆