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.
Just remember than in VS2008, runnint tests with VS Tests, this value leads incorrect results.
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/