views:

136

answers:

2

I imported system.web into my class lib project.

Trying to find:

system.web.httpserverutility.server.mappath

But I dont' get the method in intellisense?

It is a .net 2.0 build.

+6  A: 

MapPath is an instance method; you can only call it on an instance of HttpServerUtility.
If you know that your code will only be called during an HTTP request, you can call HttpContext.Current.Server.MapPath.

Otherwise, call VitualPathUtility.ToAbsolute.

SLaks
+2  A: 

The method is accessible via the System.Web.HttpContext.Current.Server object. Just set a reference to System.Web.HttpContext.Current.Server and call the method like normal.

var server = HttpContext.Current.Server;
server.MapPath(SOME_VIRTUAL_PATH);
Rodrick Chapman