|
 Saturday, March 22, 2008
« The Calendar and the Cloud | Main | Beginner Test Driven Development Habits »

TIP: Getting the Base Directory of where your App is Running

Note: I posted this quite awhile back at FooTheory but it didn't transfer over to this blog via cross posting for some reason. Internet-wackiness I call it.

 

This is an oldie but a goodie. It was brought up that not one developer at my current client knew about this object in the framework.

So, how do you find where the app is running at?

Easy: Use the AppDomain object. This works for both Web and Non-Web projects.

Code:

1 AppDomain.CurrentDomain.BaseDirectory

The AppDomain object will return the application's domain information, which includes the info about where it is executing. We get the current domain of the executing thread and then get its BaseDirectory to see where it's executing.

This:

image

Returns this:

image

 

Enjoy.

#    Comments [1] |