ini檔案一般用於儲存當前執行的程式或者一些臨時的配置屬性的檔案。也有時用於儲存一定的資料以便於臨時或者配置上的需要。
文字格式如下:
[section1 name] ---------用 括起來,其包含多個key
keyname1=value1 ------格式是 key=value。
keyname2=value2
[section2 name]
keyname1=value1
keyname2=value2
其中有專門讀寫ini檔案的windows方法:
[dllimport("kernel32")]
// 寫入ini檔案操作section,key,value
private static extern long writeprivateprofilestring(string section,string key, string val, string filepath);
[dllimport("kernel32")]
// 讀取ini檔案操作section,key,和返回的keyvalue
private static extern int getprivateprofilestring(string section,string key, string def, stringbuilder retval,int size, string filepath);
c#操作時**如下:
C 讀寫INI檔案
inifile類 using system using system.io using system.runtime.interopservices 因為我們需要呼叫api函式,所以必須建立system.runtime.interopservices命名空間以提供可用於訪問 net 中的 com 物...
C 讀寫INI檔案
using system using system.drawing using system.collections using system.componentmodel using system.windows.forms using system.io using system.runtime...
C 讀寫ini檔案
using system.text using system.runtime.interopservices dllimport kernel32 private static extern long writeprivateprofilestring string section,string k...