简体   繁体   English

Server.MapPath - 给定的物理路径,预期的虚拟路径

[英]Server.MapPath - Physical path given, virtual path expected

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". “物理路径给定但预期虚拟路径”。

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? 我在C#中使用System.IO是否足够新,所以我想知道是否可以输入物理路径来执行此操作?

如果您已经知道您的文件夹是: E:\\ ftproot \\ sales那么您不需要使用Server.MapPath,如果您只有〜/ folder / folder1之类的相对虚拟路径并且您想知道磁盘中的真实路径......

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

暂无
暂无

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

相关问题 StreamReader Server.MapPath-给定的物理路径,预期的虚拟路径 - StreamReader Server.MapPath - Physical path given, virtual path expected c# - 给定物理路径,Server.MapPath 中需要虚拟路径 - c# - Physical path given, virtual path expected in Server.MapPath Server.MapPath不会返回映射到Web-App子文件夹中的虚拟目录的正确物理路径 - Server.MapPath does not return the right physical path mapped to a virtual directory in Web-App subfolder Server.MapPath(virtualPath)返回控制器的根目录,也不返回IIS中虚拟目录中提到的物理路径 - Server.MapPath(virtualPath) Returns root directory of controller, it is nor returns the physical path mentioned in the virtual directory in IIS 使用server.MapPath()时不允许使用相对虚拟路径 - Relative virtual path is not allowed when using server.MapPath() Server.MapPath给出了错误的路径,在IIS服务器上运行时出现异常“不支持给定路径的格式”? - Server.MapPath gives wrong path, exception “The given path's format is not supported” when running on IIS server? 使用Server.MapPath()时如何从虚拟路径中排除控制器名称? - How can I exclude controller name from the virtual path when I use Server.MapPath()? c#使用Server.MapPath()找不到路径的一部分 - c# Could not find a part of the path with Server.MapPath() Server.MapPath()返回与DirectoryInfo一起使用时不存在的路径 - Server.MapPath() returning a path that does not exist when used with DirectoryInfo server.mappath 将引用的文件路径解析为相对目录 - server.mappath resolve referenced file path to relative dir
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM