Reputation: 514
I have a folder to hold images C:\inetpub\wwwroot\Images\eZone\Albums\Album1. My mvc app is in another folder C:\inetpub\wwwroot\ezone. In IIS 7, I create a virtual directory images, which maps to C:\inetpub\wwwroot\images, under ezone site. When I run my ezone app to load images from album1
DirectoryInfo di = new DirectoryInfo(Server.MapPath("/images/ezone/albums/album1"));
it returns "C:\inetput\wwwroot\ezone\images\ezone\albums\album1" which is not correct. What am I missing?
Upvotes: 2
Views: 3612
Reputation: 191
Put a tilde in front of your path:
var di = new DirectoryInfo(Server.MapPath("~/images/ezone/albums/album1"));
For more information, have a look at ASP.NET MapPath resolves Virtual, Physical Paths
Upvotes: 2