1

Here is my directory to my server (permissions are good):

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

Here I am accessing it:

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

And here is the error:

enter image description here

Any help would be great. I don't understand why it won't map the path to the UNC.

rainhider
  • 49
  • 1
  • 4
  • 13

2 Answers2

3

You can only use MapPath on a path that is inside the web application. Any path outside the web application doesn't have a corresponding URL.

Besides, the DirectoyInfo method doesn't have any use for an URL, so you should simply not use MapPath at all:

DirectoryInfo directory = new DirectoryInfo(ServerPath);
Guffa
  • 687,336
  • 108
  • 737
  • 1,005
3

Try not using the server.MapPath:

DirectoryInfo directory = new DirectoryInfo("\\\\servername\\Public\\Intranet2007Docs");
Dany Gauthier
  • 800
  • 6
  • 16
  • This was the issue...it didn't like the mappath! Using the unc directly inside worked like a charm! Thanks! – rainhider Dec 10 '12 at 19:35