C 獲取應當程式當前目錄的方法

2021-04-23 10:56:32 字數 488 閱讀 4847

1、environment.currentdirectory

private void button1_click(object sender, system.eventargs e)



private void button2_click(object sender, system.eventargs e)



上面兩種方法都很簡單,但是很遺憾,不為.net compact framework(.net精簡類庫)支援,不能應用於移動裝置作業系統(pocket pc和windows mobile支援)。於是還有下一種方法:

3、system.reflection.assembly.getexecutingassembly().location

private void button3_click(object sender, system.eventargs e)



C 獲取程式執行目錄當前目錄

獲取程式的基目錄。獲取模組的完整路徑。system.diagnostics.process.getcurrentprocess mainmodule.filename 獲取和設定當前目錄 該程序從中啟動的目錄 的完全限定目錄。system.environment.currentdirectory 獲...

C 獲取當前目錄

答案一答案二 獲取新的 process 元件並將其與當前活動的程序關聯的主模組的完整路徑,包含檔名 程序名 string str system.diagnostics.process.getcurrentprocess mainmodule.filename result x exe exe檔案所在...

C 獲取當前目錄

1 獲得當前執行的exe的檔名 string filename process.getcurrentprocess mainmodule.filename 2 獲取和設定當前目錄 即該程序從中啟動的目錄 的完全限定路徑。string path environment.currentdirectory...