2008-11-18 90 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)