![](/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.