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

by Donn Felker 22. March 2008 21:55

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.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Donn Felker

Senior Consultant
MCTS
ScrumMaster
Agile Practitioner

About Me | Books I Recommend

Gotta Pay The Bills


Tag cloud

    Popular Posts

    RecentComments

    Comment RSS

    Calendar

    <<  January 2009  >>
    MoTuWeThFrSaSu
    2930311234
    567891011
    12131415161718
    19202122232425
    2627282930311
    2345678

    View posts in large calendar