C # Help class for operating the ini configuration file
Public class IniFile
{
Public string path;
[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 );
// Construct the initialization file path
Public IniFile (string INIPath)
{
Path = INIPath;
}
// Write information
Public void IniWriteValue (string Section, string Key, string Value)
{
WritePrivateProfileString (Section, Key, Value, this. path );
}
// Read information
Public string IniReadValue (string Section, string Key)
{
StringBuilder temp = new StringBuilder (255 );
Int I = GetPrivateProfileString (Section, Key, "", temp, 255, this. path );
Return temp. ToString ();
}
}
Author "my website"