2008-11-18 88 views

回答

15

你可以嘗試

System.AppDomain.CurrentDomain.BaseDirectory 

這將在大多數情況下工作。

4

編輯:@ KiwiBastard的答案是正確的方法:

System.AppDomain.CurrentDomain.BaseDirectory 

增加提及System.Reflection和使用

Assembly.GetExecutingAssembly().Location 

編輯:根據你打算獲得啓動路徑,這可能更合適:

Assembly.GetEntryAssembly().Location 
+0

@ KiwiBastard的答案很可能是正確的方法... – 2008-11-19 00:17:54

3

您可以通過使用獲得無反射的啓動路徑:

IO.Path.GetDirectoryName(Diagnostics.Process.GetCurrentProcess().MainModule.FileName)