![](/img/trans.png)
[英]What's the difference between GetFullPath(".") and Directory.GetCurrentDirectory()?
[英]C#-Difference between System.CurrentDomain.AppDomain.BaseDirectory and Directory.GetCurrentDirectory()
谁能告诉我C#中System.CurrentDomain.AppDomain.BaseDirectory
和Directory.GetCurrentDirectory()
之间的区别是什么?
请参阅MSDN上的AppDomain以及MSDN上的 Directory.GetCurrentDirectory() 。
根据这个问题 ,不同之处在于
System.AppDomain.CurrentDomain.BaseDirectory返回当前目录,而不是可执行位置,即从outlook运行时(作为链接发送到\\ server \\ folder \\ file.exe,它将BaseDirectory设置为用户文档,而不是来自Jakub Pawlinski而不是
Directory.GetParent(Assembly.GetExecutingAssembly().Location)
可执行位置Directory.GetParent(Assembly.GetExecutingAssembly().Location)
获取当前exulateing程序集的父文件夹。
所以我现在使用的代码是:
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.