Get Application Path for ASP.NET

To get the full application path (for example to a folder named Documents) in ASP.NET do the following.

1. If you are on a webpage you can use the request object.

string DocPath = Request.MapPath(@"/Documents/");

2. If you are in a class you can use HTTPContext

string DocPath = HttpContext.Current.Request.MapPath(@"/Documents/");

Result: E:\Development\VS2010\MailMerge\MailMerge\Documents\

Comments are closed