Winform获取应用程序的当前路径汇总(红色为常用)
- string Path = this.GetType().Assembly.Location;//获取当前进程的完整路径,包含文件名(进程名)。
- string Path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;//获取新的Process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。
- string Path = System.Environment.CurrentDirectory;//获取和设置当前目录(即该进程从中启动的目录)的完全限定路径。
- string Path = System.AppDomain.CurrentDomain.BaseDirectory;//获取当前应用程序根目录。
- string Path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;//获取和设置包含该应用程序的目录的名称。
- string Path = System.Windows.Forms.Application.StartupPath;//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。
- string Path = System.Windows.Forms.Application.ExecutablePath;//获取启动了应用程序的可执行文件的路径,包括可执行文件的名称。
- string Path = System.IO.Directory.GetCurrentDirectory();//获取应用程序的当前工作目录(不可靠)。