[英]C#-Difference between System.CurrentDomain.AppDomain.BaseDirectory and Directory.GetCurrentDirectory()
Can anyone tell me what's the difference between System.CurrentDomain.AppDomain.BaseDirectory
and Directory.GetCurrentDirectory()
in C#, please?? 谁能告诉我C#中
System.CurrentDomain.AppDomain.BaseDirectory
和Directory.GetCurrentDirectory()
之间的区别是什么?
See AppDomain on MSDN and also Directory.GetCurrentDirectory() on MSDN . 请参阅MSDN上的AppDomain以及MSDN上的 Directory.GetCurrentDirectory() 。
According to this question the difference is that 根据这个问题 ,不同之处在于
System.AppDomain.CurrentDomain.BaseDirectory returns current directory, not executable location, ie when run from outlook (sent as a link to \\server\\folder\\file.exe it will set BaseDirectory to user documents instead executable location from Jakub Pawlinski whereas
Directory.GetParent(Assembly.GetExecutingAssembly().Location)
gets the parent folder of the current execting assembly.System.AppDomain.CurrentDomain.BaseDirectory返回当前目录,而不是可执行位置,即从outlook运行时(作为链接发送到\\ server \\ folder \\ file.exe,它将BaseDirectory设置为用户文档,而不是来自Jakub Pawlinski而不是
Directory.GetParent(Assembly.GetExecutingAssembly().Location)
可执行位置Directory.GetParent(Assembly.GetExecutingAssembly().Location)
获取当前exulateing程序集的父文件夹。
So the code I'm using now is: 所以我现在使用的代码是:
string location = Assembly.GetExecutingAssembly().Location;
if (location != null)
{
string config = Path.Combine(Directory.GetParent(location).FullName, "Config.xml"));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.