整理记录,以备自己查询用。
1、获取模块的完整路径
- System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
如:E:\WindowsFormsApplication\bin\Release(Debug)\WindowsFormsApplication.vshost.exe
- System.Windows.Forms.Application.ExecutablePath
如:E:\WindowsFormsApplication\bin\Release(Debug)\WindowsFormsApplication.EXE
2、获取当前目录的完全限定目录(应用程序的可执行文件的路径)
- System.Environment.CurrentDirectory
如:E:\WindowsFormsApplication\bin\Release(Debug)
- System.Windows.Forms.Application.StartupPath
如:E:\WindowsFormsApplication\bin\Release(Debug)
- System.IO.Directory.GetCurrentDirectory()
如:E:\WindowsFormsApplication\bin\Release(Debug)
3、获取程序的基目录
- System.AppDomain.CurrentDomain.BaseDirectory
如:E:\WindowsFormsApplication\bin\Release(Debug)\
- System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase
如:E:\WindowsFormsApplication\bin\Release(Debug)\