Using system; using system. collections. generic; using system. LINQ; using system. text; namespace register {// <summary> // config class // </Summary> public class config {Public String inipath; private stringbuilder temp = new stringbuilder (128); [system. runtime. interopservices. dllimport ("Kernel32", charset = system. runtime. interopservices. charset. ANSI)] Private Static extern int writeprivateprofilestring (string section, string key, string Val, string filepath); [system. runtime. interopservices. dllimport ("Kernel32", charset = system. runtime. interopservices. charset. ANSI)] Private Static extern int getprivateprofilestring (string section, string key, string def, stringbuilder retval, int size, string filepath ); /// <summary> /// write the INI file /// </Summary> /// <Param name = "section"> Project Name (for example, [typename]) </param> /// <Param name = "key"> key </param> /// <Param name = "value"> value </param> Public void write (string section, string key, string value) {writeprivateprofilestring (section, key, value, this. inipath );} /// <summary> /// read the INI file /// </Summary> /// <Param name = "section"> Project Name (for example, [typename]) </param> // <Param name = "key"> key </param> Public String read (string section, string key) {getprivateprofilestring (section, key ,"", temp, 128, this. inipath); Return temp. tostring ();}} /// <summary> // error class /// </Summary> public class error {// <summary> /// write error message /// </Summary> /// <Param name = "Err"> error description </param> Public static void write (Ref system. exception ex) {string err = datetime. now. tostring () + "" + ex. message + "" + ex. stacktrace + "\ r \ n"; system. io. file. appendalltext (system. windows. forms. application. startuppath + "\ error. log ", err, system. text. encoding. utf8 );}}}