public static string[] INIGetAllItemKeys(string iniFile, string section) { string[] value = new string[0]; const int SIZE = 1024 * 10; if (string.IsNullOrEmpty(section)) { throw new ArgumentException("The name of the node must be specified", "section"); } char[] chars = new char[SIZE]; uint bytesReturned = IniHelper.GetPrivateProfileString(section, null, null, chars, SIZE, iniFile); if (bytesReturned != 0) { value = new string(chars).Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); } chars = null; return(value); }
public static string INIGetStringValue(string iniFile, string section, string key, string defaultValue) { string value = defaultValue; const int SIZE = 1024 * 10; if (string.IsNullOrEmpty(section)) { throw new ArgumentException("The name of the node must be specified", "section"); } if (string.IsNullOrEmpty(key)) { throw new ArgumentException("You must specify the key", "key"); } StringBuilder sb = new StringBuilder(SIZE); uint bytesReturned = IniHelper.GetPrivateProfileString(section, key, defaultValue, sb, SIZE, iniFile); if (bytesReturned != 0) { value = sb.ToString(); } sb = null; return(value); }