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?
 
Request.ApplicationPath ?
Request.PhysicalApplicationPath
 
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
-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top