偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

C#獲取相對路徑的八種方法

開發(fā) 后端
這八種C#獲取相對路徑的方法,包括獲取和設置當前目錄的完全限定路徑、獲取啟動了應用程序的可執(zhí)行文件的路徑,不包括可執(zhí)行文件的名稱等等內(nèi)容。

C#獲取相對路徑1.

獲取和設置當前目錄的完全限定路徑。

  1. string str = System.Environment.CurrentDirectory;  
  2. Result: C:\xxx\xxx 

C#獲取相對路徑2.

獲取啟動了應用程序的可執(zhí)行文件的路徑,不包括可執(zhí)行文件的名稱。

  1. string str = System. Windows .Forms.Application.StartupPath;  
  2. Result: C:\xxx\xxx 

C#獲取相對路徑3.

獲取新的 Process 組件并將其與當前活動的進程關聯(lián)的主模塊的完整路徑,包含文件名。

  1. string str = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;  
  2. Result: C:\xxx\xxx\xxx.exe 

C#獲取相對路徑4.

獲取當前 Thread 的當前應用程序域的基目錄,它由程序集沖突解決程序用來探測程序集。

  1. string str = System.AppDomain.CurrentDomain.BaseDirectory;  
  2. Result: C:\xxx\xxx\ 

C#獲取相對路徑5.

獲取應用程序的當前工作目錄。

  1. string str = System.IO.Directory.GetCurrentDirectory();  
  2. Result: C:\xxx\xxx 

C#獲取相對路徑6.

獲取和設置包含該應用程序的目錄的名稱。

  1. string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;  
  2. Result: C:\xxx\xxx\ 

C#獲取相對路徑7.

獲取當前進程的完整路徑,包含文件名。

  1. string str = this.GetType().Assembly.Location;  
  2. Result: C:\xxx\xxx\xxx.exe 

C#獲取相對路徑8.

獲取啟動了應用程序的可執(zhí)行文件的路徑,包括可執(zhí)行文件的名稱。

  1. string str = System. Windows .Forms.Application.ExecutablePath;  
  2. Result: C:\xxx\xxx\xxx.exe 

此外,更多見的通過XML文件配置具體的路徑來達到合理的規(guī)劃配置文件的具體存放位置,如WEB中的配置文件中的路徑。

【編輯推薦】

  1. C#記憶功能的地址欄控件
  2. 描述C#調用外部進程
  3. C#語言操縱數(shù)據(jù)庫事務
  4. 概述C#語言異常處理
  5. 簡單介紹C#數(shù)組和函數(shù)
責任編輯:彭凡 來源: .rocsky.net
相關推薦

2009-08-06 18:31:57

C#相對路徑絕對路徑

2009-08-06 18:03:21

C#相對路徑

2009-08-07 13:16:27

c#相對路徑寫法

2009-08-07 13:38:18

C#文件相對路徑

2009-08-28 16:06:57

C#獲取當前路徑方法

2010-03-18 08:48:30

Python入門

2010-06-23 17:26:01

2011-07-11 13:29:03

JAVA

2011-06-23 15:33:24

SEO

2009-08-07 14:00:06

C#路徑

2021-08-04 10:15:14

Go路徑語言

2022-11-16 10:13:29

Linux相對路徑絕對路徑

2022-08-29 14:11:10

Linux絕對路徑相對路徑

2021-07-29 20:28:24

靜態(tài)代碼Hdfs

2025-03-26 00:12:00

C#重構代碼

2022-04-24 15:33:38

鴻蒙開發(fā)操作系統(tǒng)

2023-12-29 09:23:25

Python回調函數(shù)遍歷字典

2009-09-17 16:55:58

C#組件設計

2009-08-18 13:22:55

C#動態(tài)調用Web服務

2009-07-30 16:27:33

C#比較時間
點贊
收藏

51CTO技術棧公眾號