• C# 写App.config配置文件的方法


    private static void AccessAppSettings()
    {
    //获取Configuration对象
    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
    //根据Key读取<add>元素的Value
    string name = config.AppSettings.Settings["count"].Value;
    //写入<add>元素的Value
    config.AppSettings.Settings["count"].Value = "fx163";
    //增加<add>元素
    config.AppSettings.Settings.Add("url", "http://www.fx163.net");
    //删除<add>元素
    config.AppSettings.Settings.Remove("name");
    //一定要记得保存,写不带参数的config.Save()也可以
    config.Save(ConfigurationSaveMode.Modified);
    //刷新,否则程序读取的还是之前的值(可能已装入内存)
    ConfigurationManager.RefreshSection("appSettings");
    }

    转载:https://www.cnblogs.com/feiyuhuo/p/5243967.html

  • 相关阅读:
    安装 Android 运行环境
    Sea.js
    css hack 兼容性
    solr全文检索基本原理
    Solr初步学习
    jquery中ajax的用法
    Javascript的模块化编程
    html 标签
    CSS盒子模型
    python 初学03 Eric+PyQt+python IDE与界面程序
  • 原文地址:https://www.cnblogs.com/uftwkb24/p/9914465.html
Copyright © 2020-2023  润新知