Tuesday, 20 August 2013

How to get the application path in C#.NET

First Get the ASP.NET application's virtual application root path on the server using HttpRequest.ApplicationPath Property.

string appPath = HttpContext.Current.Request.ApplicationPath;

Now map the specified virtual path to a physical path using Request.MapPath() Method.

string physicalPath = HttpContext.Current.Request.MapPath(appPath);

No comments: