/// <summary>
        /// 写入web.config
        /// </summary>
        /// <param name="item">appSettings等</param>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static void WriteConfig(string item, string key, string value)
        {
            if (item == "")
            {
                item = "appSettings";
            }
            Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath);
            AppSettingsSection appSection = (AppSettingsSection)config.GetSection(item);
            if (appSection.Settings[key] == null)
            {
                appSection.Settings.Add(key, value);
                config.Save();
            }
            else
            {
                appSection.Settings.Remove(key);
                appSection.Settings.Add(key, value);
                config.Save();
            }
        }

 

相关文章:

  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2021-07-18
  • 2021-07-05
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2021-08-12
相关资源
相似解决方案