I need to get all dlls in my application root directory. What is the best way to do that?
string root = Application.StartupPath;
Or,
string root = new FileInfo(Assembly.GetExecutingAssembly().Location).FullName;
And after that,
Directory.GetFiles(root, '*.dll');
Which way is better? Are there better ways?
AppDomain.CurrentDomain.BaseDirectoryis my go to way of doing so.However:
Application.StartupPathgets the directory of your executableAppDomain.BaseDirectorygets the directory used to resolve assembliesSince they can be different, perhaps you want to use Application.StartupPath, unless you care about assembly resolution.