Not a subscriber?

Join thousands of others who are building self-directed lives through creativity, grit, and digital strategy—breaking free from the 9–5.
Receive one free message a week

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.