Server.MapPath给UNC带来错误

时间:2012-12-07 15:31:21

标签: c# unc server.mappath mappath

这是我的服务器目录(权限很好):

string ServerPath = ("\\\\servername\\Public\\Intranet2007Docs");

我在这里访问它:

DirectoryInfo directory = new DirectoryInfo(Server.MapPath(ServerPath));

这是错误:

enter image description here

任何帮助都会很棒。我不明白为什么它不会映射到UNC的路径。

2 个答案:

答案 0 :(得分:3)

您只能在Web应用程序内部的路径上使用MapPath。 Web应用程序之外的任何路径都没有相应的URL。

此外,DirectoyInfo方法对网址没有任何用处,因此您根本不应使用MapPath

DirectoryInfo directory = new DirectoryInfo(ServerPath);

答案 1 :(得分:3)

尝试不使用server.MapPath:

DirectoryInfo directory = new DirectoryInfo("\\\\servername\\Public\\Intranet2007Docs");
相关问题