Using system; using system. collections. generic; using system. LINQ; using system. web; using system. runtime. interopservices; using system. text; using system. io; // <summary> /// INI file read/write class. /// </Summary> public class INIFILE {Public String path; Public INIFILE (string inipath) {Path = inipath;} [dllimport ("Kernel32")] private Static extern long writeprivateprofilestring (string section, string key, string Val, string filepath); [dllimport ("Kernel32")] Private Static extern int getprivateprofilestring (string section, string key, string def, stringbuilder retval, int size, string filepath); [dllimport ("Kernel32")] Private Static extern int getprivateprofilestring (string section, string key, string defval, byte [] retval, int size, string filepath ); /// <summary> /// write the INI file /// </Summary> /// <Param name = "section"> </param> /// <Param name = "key"> </param> // <Param name = "value"> </param> Public void iniwritevalue (string section, string key, string value) {writeprivateprofilestring (section, key, value, this. path );} /// <summary> /// read the INI file /// </Summary> /// <Param name = "section"> </param> /// <Param name = "key"> </param> // <returns> </returns> Public String inireadvalue (string section, string key) {stringbuilder temp = new stringbuilder (255); int I = getprivateprofilestring (section, key, "", temp, 255, this. path); return temp. tostring ();} public byte [] inireadvalues (string section, string key) {byte [] temp = new byte [255]; int I = getprivateprofilestring (section, key, "", temp, 255, this. path); return temp;} // <summary> // delete all paragraphs in the INI file // </Summary> Public void clearallsection () {iniwritevalue (null, null, null );} /// <summary> /// delete all keys in the personal section of the INI file /// </Summary> /// <Param name = "section"> </param> public void clearsection (string section) {iniwritevalue (section, null, null );}}