예제 #1
0
    /// <summary>
    /// 在INI文件中,删除指定节点中的所有内容。
    /// </summary>
    /// <param name="iniFile">INI文件</param>
    /// <param name="section">节点</param>
    /// <returns>操作是否成功</returns>
    public static bool INIEmptySection(string iniFile, string section)
    {
        if (string.IsNullOrEmpty(section))
        {
            throw new ArgumentException("必须指定节点名称", "section");
        }

        return(INIOperationHelper.WritePrivateProfileSection(section, string.Empty, iniFile));
    }
예제 #2
0
    /// <summary>
    /// 在INI文件中,将指定的键值对写到指定的节点,如果已经存在则替换
    /// </summary>
    /// <param name="iniFile">INI文件</param>
    /// <param name="section">节点,如果不存在此节点,则创建此节点</param>
    /// <param name="items">键值对,多个用\0分隔,形如key1=value1\0key2=value2</param>
    /// <returns></returns>
    public static bool INIWriteItems(string iniFile, string section, string items)
    {
        if (string.IsNullOrEmpty(section))
        {
            throw new ArgumentException("必须指定节点名称", "section");
        }

        if (string.IsNullOrEmpty(items))
        {
            throw new ArgumentException("必须指定键值对", "items");
        }

        return(INIOperationHelper.WritePrivateProfileSection(section, items, iniFile));
    }