使用Server.Mappath - 物理路径给出虚拟路径预期 [英] Server.MapPath - Physical path given, virtual path expected

查看:127
本文介绍了使用Server.Mappath - 物理路径给出虚拟路径预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这行code的:

I'm using this line of code:

var files = Directory.GetFiles(Server.MapPath("E:\\ftproot\\sales"));

要查找某个文件夹中的文件,但是我得到的错误消息说,

to locate files in a folder however I get the error message saying that

物理路径给出,但虚拟路径
  预期。

"Physical Path given but virtual path expected".

是新足以在C#中使用System.IO所以我在想,如果有可能进入这样做的物理路径?

Am new enough to using System.IO in C# so I was wondering if it's possible to enter a physical path to do this?

推荐答案

如果你已经知道你的文件夹为: E:\\ FTPROOT \\销售,然后你不需要使用使用Server.Mappath,这如果你只有像一个相对虚拟路径需要的最后一个〜/文件夹/文件夹1 并要知道在磁盘上的真实路径......

if you already know your folder is: E:\ftproot\sales then you do not need to use Server.MapPath, this last one is needed if you only have a relative virtual path like ~/folder/folder1 and you want to know the real path in the disk...

这篇关于使用Server.Mappath - 物理路径给出虚拟路径预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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