ConfigurationManager配置操作

ConfigurationManager配置操作
/// <summary>
    /// 配置信息维护
    /// </summary>
    public class AppConfig
    {
        public static Configuration config = ConfigurationManager.OpenExeConfiguration(<SPAN style="COLOR: #ff0000">ConfigurationUserLevel.None</SPAN>);

        /// <summary>
        /// 获取配置值
        /// </summary>
        /// <param name="key">配置标识</param>
        /// <returns></returns>
        public static string GetValue(string key)
        {
            string result = string.Empty;
            if (config.AppSettings.Settings[key] != null)
                result = config.AppSettings.Settings[key].Value;
            return result;
        }

        /// <summary>
        /// 修改或增加配置值
        /// </summary>
        /// <param name="key">配置标识</param>
        /// <param name="value">配置值</param>
        public static void SetValue(string key, string value)
        {
            if (config.AppSettings.Settings[key] != null)
                config.AppSettings.Settings[key].Value = value;
            else
                config.AppSettings.Settings.Add(key, value);
            config.Save(ConfigurationSaveMode.Modified);
} /// <summary> /// 删除配置值 /// </summary> /// <param name="key">配置标识</param> public static void DeleteValue(string key) { config.AppSettings.Settings.Remove(key); } }
ConfigurationManager配置操作

ConfigurationManager配置操作

上一篇:ios和node上传下载文件


下一篇:HDU 1159 Common Subsequence