c# winform 获取当前程序运行根目录

1 // 获取程序的基目录。

2 System.AppDomain.CurrentDomain.BaseDirectory

3

4

5 // 获取模块的完整路径。

6 System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName

7

8

9 // 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。

10 System.Environment.CurrentDirectory

11

12

13 // 获取应用程序的当前工作目录。

14 System.IO.Directory.GetCurrentDirectory()

15

16

17 // 获取和设置包括该应用程序的目录的名称。

18 System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase

19

20

21 // 获取启动了应用程序的可执行文件的路径。

22 System.Windows.Forms.Application.StartupPath

23

24

25 // 获取启动了应用程序的可执行文件的路径及文件名

26 System.Windows.Forms.Application.ExecutablePath