自己寫的ini 檔案操作的類

2021-04-12 19:40:05 字數 2080 閱讀 3649

ini 檔案操作的類

今天沒有什麼工作,找了些資料,寫乙個操作ini檔案的類,已經測試過了,也算是技術積累吧!哈哈.......

using system;

using system.collections.generic;

using system.text;

using system.runtime.interopservices;

namespace inifile

///

/// 向ini檔案中寫資料

///

/// 項

/// 關鍵字

/// 值

///

public long setvalue(string section, string key, string value)

///

/// 從ini檔案中的專案下的關鍵字中讀資料

///

/// 項

/// 關鍵字

///

private string getvalues(string section, string key)

while (icount == ibuffersize - 2);

for (int i = 0; i < icount; ++i)

if (i > 0 && buff[i - 1] == 0 && buff[i] == 0) break;

}string strresult = encoding.default.getstring(buff).trim();

return strresult.trim(new char ).split(new char );

}///

/// 根據項和關鍵字讀取資料值

///

///

///

///

public string getvalue(string section, string key)

return getvalues(section, key)[0];

}///

/// 根據項讀取所有的關鍵字

///

/// 項

/// 字串陣列

public string getkeys(string section)

return getvalues(section, null);

}///

/// 獲取ini檔案中所有的項

///

/// 字串陣列

public string getsections()                           

///

/// 設定項下關鍵子對應的數字

///

/// 項

/// 關鍵字

/// 數字

/// 數字型別long

public long setvalueint(string section, string key, int value)

///

/// 獲取項下關鍵字所對應的數字值

///

/// 項

/// 關鍵字

/// 數字值

public int getvalueint(string section, string key)

///

/// 設定項下的關鍵字

///

/// 項

/// 關鍵字

/// 數字型別int

public int setsection(string strsection, string strkeyvalue)

///

/// 刪除項下的所有內容

///

/// 項

///

public int deletesection(string strsection)

///

/// 刪除項下的關鍵字

///

///

///

///

public long  deletekey(string strsection, string strkey)}}

ini檔案操作類

using system using system.io using system.runtime.interopservices using system.text using system.collections using system.collections.specialized name...

Ini檔案操作類

using system using system.runtime.interopservices using system.text namespace win.cfg set public inifile string path windows api 對ini檔案寫方法 要在其中寫入新字串的小...

共享自己寫的測試ini 檔案讀寫原始碼

bool ctest131dlg readini 讀ini int ctest131dlg calccount char psectionname 儲存找到的某個節名字串的首位址 int i 指向陣列chsectionnames的某個位置,從0開始,順序後裔 int j 0 用來儲存下乙個節名字串的...