以前都是直接解析Web.config来操作,现在发现可以这样做,      

       //打开配置文件   
       Configuration   config   =   WebConfigurationManager.OpenWebConfiguration("~");   
      //获取appSettings节点   
      AppSettingsSection   appSection   =   (AppSettingsSection)config.GetSection("appSettings");   
      //删除appSettings节点中的元素   
      appSection.Settings.Remove("addkey1");   
      //修改appSettings节点中的元素   
      appSection.Settings["addkey2"].Value   =   "Modify   key2's   value";   
      config.Save();       

相关文章:

  • 2021-11-28
  • 2022-12-23
  • 2021-12-09
  • 2021-11-29
  • 2022-12-23
  • 2021-07-27
  • 2021-06-28
猜你喜欢
  • 2021-10-10
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2022-02-23
相关资源
相似解决方案