c#中路徑寫法(@"c:\") or ("c:\\子目錄")
可獲得當前執行的exe的文件名。
Process.GetCurrentProcess().MainModule.FileName;
獲取該進程從中啟動的目錄
Environment.CurrentDirectory;
備注按照定義,如果該進程在本地或網絡驅動器的根目錄中啟動,則此屬性的值為驅動器名稱后跟一個尾部反斜杠(如“C:\”)。如果該進程在子目錄中啟動,則此屬性的值為不帶尾部反斜杠的驅動器和子目錄路徑
(如“C:\子目錄”)。
獲取應用程序的當前工作目錄。
Directory.GetCurrentDirectory();
獲取基目錄,它由程序集沖突解決程序用來探測程序集。
AppDomain.CurrentDomain.BaseDirectory;
獲取啟動了應用程序的可執行文件的路徑,不包括可執行文件的名稱。
Application.StartupPath;
獲取啟動了應用程序的可執行文件的路徑,包括可執行文件的名稱。
Application.ExecutablePath;
獲取或設置包含該應用程序的目錄的名稱。
AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
獲取模塊的完整路徑。
System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
獲取和設置當前目錄(該進程從中啟動的目錄)的完全限定目錄。
System.Environment.CurrentDirectory
獲取應用程序的當前工作目錄。
System.IO.Directory.GetCurrentDirectory()
獲取程序的基目錄。
System.AppDomain.CurrentDomain.BaseDirectory
獲取和設置包括該應用程序的目錄的名稱。
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase
獲取啟動了應用程序的可執行文件的路徑。
System.Windows.Forms.Application.StartupPath
獲取啟動了應用程序的可執行文件的路徑及文件名
System.Windows.Forms.Application.ExecutablePath