It depends. If you want the EXE directory to run the application, then either of your two examples will work. Remember, however, that .NET is very flexible, and it may be that another application is associated with your EXE and calls it, possibly from a different directory.
This does not happen very often, and you would probably write if that were the case, but it is an opportunity. Because of this, I prefer to specify which assembly I am interested in and get a catalog from it. Then I know that I get all the DLLs in the same directory as the specific assembly. For example, if you have a MyApp.exe application with the class in it MyApp.MyClass, then you will do this:
string root = string.Empty; Assembly ass = Assembly.GetAssembly( typeof( MyApp.MyClass ) ); if ( ass != null ) { root = ass.Location; }
Rob Prouse Dec 12 '08 at 14:10 2008-12-12 14:10
source share