/// <summary> /// 在INI文件中,删除指定的节点。 /// </summary> /// <param name="section">节点</param> /// <returns>操作是否成功</returns> public static bool DeleteSection(string iniPath, string section) { if (string.IsNullOrEmpty(section)) { throw new ArgumentException("必须指定节点名称", "section"); } return(IniFileHelper.WritePrivateProfileString(section, null, null, iniPath)); }
/// <summary> /// 在INI文件中,指定节点写入指定的键及值。如果已经存在,则替换。如果没有则创建。 /// </summary> /// <param name="section">节点</param> /// <param name="key">键</param> /// <param name="value">值</param> /// <returns>操作是否成功</returns> public static bool WriteValue(string iniPath, string section, string key, string value) { if (string.IsNullOrEmpty(section)) { throw new ArgumentException("必须指定节点名称", "section"); } if (string.IsNullOrEmpty(key)) { throw new ArgumentException("必须指定键名称", "key"); } if (value == null) { throw new ArgumentException("值不能为null", "value"); } return(IniFileHelper.WritePrivateProfileString(section, key, value, iniPath)); }