programmatically finding the application root

  • Thread starter Thread starter Joel Barsotti
  • Start date Start date
J

Joel Barsotti

If I have a class that I use in multiple applications (nested within a
single website), is there anyway programmatically to find out what which
directory is the application root?
 
Joel said:
If I have a class that I use in multiple applications (nested within a
single website), is there anyway programmatically to find out what which
directory is the application root?

Here is a method I wrote that I use in a utility class.

public static string AppRoot
{
get
{
HttpContext context = HttpContext.Current;
string basePath = "";
string pathName = context.Request.ApplicationPath;
if ( pathName.Trim() != "/" )
{
basePath += pathName;
}
return basePath;
}
}

Regards,

Aaron Prohaska

-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-
Wrench Science Inc.
http://www.wrenchScience.com/
Phone: 510.841.4748 x206
Fax: 510.841.4708
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-
 
Back
Top