Created
December 13, 2012 19:23
-
-
Save RobertMischke/4278997 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
public IniFile(string iniPath) | |
{ | |
Path = iniPath; | |
} | |
public void WriteValue(string section, string key, string value) | |
{ | |
WritePrivateProfileString(section, key, value, Path); | |
} | |
public string ReadValue(string section, string key) | |
{ | |
var sb = new StringBuilder(255); | |
int i = GetPrivateProfileString(section, key, "", sb, 255, Path); | |
return sb.ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment