close
01.1.取得和設置當前目錄(即該進程從中啟動的目錄)的完全限定路徑。
02.string str = System.Environment.CurrentDirectory;
03.結果: C:\xxx\xxx
04. 
05.2.取得啟動了應用程序的可執行文件的路徑,不包括可執行文件的名稱。
06.string str = System.Windows.Forms.Application.StartupPath;
07.結果: C:\xxx\xxx
08. 
09.3.取得應用程序的當前工作目錄。
10.string str = System.IO.Directory.GetCurrentDirectory();
11.結果: C:\xxx\xxx
12. 
13.4.取得當前 Thread 的當前應用程序域的基目錄,它由程序集衝突解決程序用來探測程序集。
14.string str = System.AppDomain.CurrentDomain.BaseDirectory;
15.結果: C:\xxx\xxx\
16. 
17.5.取得和設置包含該應用程序的目錄的名稱。
18.string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
19.結果: C:\xxx\xxx\
20. 
21.6.取得啟動了應用程序的可執行文件的路徑,包括可執行文件的名稱。
22.string str = System.Windows.Forms.Application.ExecutablePath;
23.結果: C:\xxx\xxx\xxx.exe
24. 
25.7.取得當前執行的exe的文件名。
26.string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
27.結果: C:\xxx\xxx\xxx.exe
28. 
29.8.取得當前進程的完整路徑,包含文件名。
30.string str = this.GetType().Assembly.Location;
31.結果: C:\xxx\xxx\xxx.exe
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Allen 的頭像
    Allen

    Allen的部落格

    Allen 發表在 痞客邦 留言(0) 人氣()