Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private const char CommentDelimiter = ';';
- [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 static void IniWriteValue(string filePath, string section, string key, string value, string comment)
- {
- var str = string.Format(" {0}", value);
- if (comment != null) str += string.Format(" {0} {1} ", CommentDelimiter, comment);
- WritePrivateProfileString(section, key, str, filePath);
- }
- public static string IniReadValue(string filePath, string section, string key)
- {
- var temp = new StringBuilder(255);
- GetPrivateProfileString(section, key, "", temp, 255, filePath);
- return temp.ToString().Split(CommentDelimiter)[0].Trim();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement