什么是确定应用程序的根目录下的最佳方法是什么? [英] What is the best way to determine application root directory?
问题描述
我需要把所有的DLL在我的应用程序根目录。什么是做到这一点的最好方法是什么?
串根= Application.StartupPath;
或者
串根=新的FileInfo(Assembly.GetExecutingAssembly()位置。).FullName;
在这之后,
Directory.GetFiles(根的* .dll);
哪种方法更好呢?有没有更好的办法呢?
AppDomain.CurrentDomain.BaseDirectory
是我去这样做的方式。
不过:</ P>
Application.StartupPath
得到您的可执行文件的目录
AppDomain.BaseDirectory
获取用于解决组件目录
由于它们可以是不同的,也许你想使用Application.StartupPath,除非你关心大会决议。
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.BaseDirectory
is my go to way of doing so.
However:
Application.StartupPath
gets the directory of your executable
AppDomain.BaseDirectory
gets the directory used to resolve assemblies
Since they can be different, perhaps you want to use Application.StartupPath, unless you care about assembly resolution.
这篇关于什么是确定应用程序的根目录下的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!