讀取ini檔案

2021-07-30 07:52:42 字數 1099 閱讀 2713

///

/// 自定義讀取ini檔案中的內容方法

//////

鍵///

值///

private

string

contentvalue(string section, string key)

////// 寫入ini檔案

//////

節點名稱[如[typename]]

///鍵

///值

///檔案路徑

/// [dllimport("kernel32")]

private

static

extern

long

writeprivateprofilestring(string section, string key, string val, string filepath);

////// 讀取ini檔案

//////

節點名稱

///鍵

///值

///stringbulider物件

///位元組大小

///檔案路徑

/// [dllimport("kernel32")]

private

static

extern

intgetprivateprofilestring(string section, string key, string def, stringbuilder retval, int size, string filepath);

private

private

string strsec = "config";

讀:

if (file.exists(strfilepath))//讀取時先要判讀ini檔案是否存在

else

寫:

//修改ini檔案

writeprivateprofilestring(strsec, "timeset", txttimeset.text.trim(), strfilepath);

讀取INI檔案

讀取ini檔案 ini ini new ini using system using system.text using system.runtime.interopservices namespace qf public string path 引用動態連線庫方法 dllimport kernel...

讀取ini檔案

1.得到當前根目錄 import os 2.ini檔案組成 注釋內容 section部分 key value 多個 section 部分 可以有多個,但section不可重複 key value 多個 3.讀取ini檔案 3.1獲取ini檔案路徑 3.2匯入 configparser 3.3 先獲得...

C 讀取INI檔案

class inifile public bool setint string szsection,string szkey,int ival public bool setstring string szsection,string szkey,string szval public uint32...