2012-12-07 39 views
0

這裏是我的目錄到我的服務器(權限都不錯):給使用Server.Mappath誤差UNC

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

在這裏,我訪問它:

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

這裏是錯誤:

enter image description here

任何幫助將是偉大的。我不明白爲什麼它不會將路徑映射到UNC。

+0

@,〜,//和。都適用於本地計算機上的目錄,並且它們無法訪問服務器。 – rainhider

回答

1

儘量不要使用使用Server.Mappath:

DirectoryInfo directory = new DirectoryInfo("\\\\servername\\Public\\Intranet2007Docs"); 
+0

這是個問題......它不喜歡這個mappath!使用unc直接在裏面工作就像一個魅力!謝謝! – rainhider

1

您只能在Web應用程序內部的路徑上使用MapPath。 Web應用程序之外的任何路徑都沒有相應的URL。

此外,DirectoyInfo方法不具有的URL任何使用,所以你應該根本不使用MapPath都:

DirectoryInfo directory = new DirectoryInfo(ServerPath);