Reputation: 1560
I am using HttpContext.Current.Server.MapPath
function in order to locate a resource in a site hosted by IIS.
HttpContext.Current.Server.MapPath("localPath")
The value that I get from it is:
c:\users\guy\documents\visual studio 2012\Projects\MyProject\MyProject\api\localPath
while the real content is in
C:\Users\guy\Documents\Visual Studio 2012\Projects\MyProject\MyProject\localPath
Why do I get an extra api
in the end? maybe it has something to do with the fact I am running a webapi app?
Thanks.
Upvotes: 4
Views: 7696
Reputation: 4476
You probably need to add ~/
to get to the root folder. Like this:
HttpContext.Current.Server.MapPath("~/")
Upvotes: 8