Reading in config files _one_ way – what’s the path?

Executive summary:  AppDomain.CurrentDomain.SetupInformation.ApplicationBase

Subscribe here: http://feeds.feedburner.com/jeffreypalermo.

In a console app, this directory is where the assemblies are.  In ASP.NET, this directory is where the web.config file is, not the assemblies.  Other methods seem to be less reliable and rely on the current directory.  This can change whether the code is executing stand-alone or through Visual Studio.  the above API seems to be very consistent.

Please share your experiences.

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

2 Responses to Reading in config files _one_ way – what’s the path?

  1. Francois Tanguay says:

    Just remember than in VS2008, runnint tests with VS Tests, this value leads incorrect results.

  2. Aaron Lerch says:

    Well the pingback beat me to it, but I have a post that lists some ways to determine “collocated” files (like .config files).

    http://www.aaronlerch.com/blog/2007/12/12/loading-collocated-file-dependencies-at-runtime/

Leave a Reply