zoukankan      html  css  js  c++  java
  • 读取和修改app.config文件

    本处主要是指读取和修改appSettings节点:

    读取:

     string port = ConfigurationManager.AppSettings["port"];  //port字符不区分大小写,但注意config文件中port前后不要有空格,否则出错

    写入:

     Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                configuration.AppSettings.Settings["port"].Value = (int.Parse(port) + 1).ToString();
                configuration.Save();
                ConfigurationManager.RefreshSection("appSettings");  //此行刷新非常重要,否则再次读到时还是旧值,并且可能也未保存到磁盘中

  • 相关阅读:
    子网划分详解
    USACO range
    USACO shopping
    USACO fence
    USACO Spinning Wheels
    USACO butter
    USACO msquare
    USACO Feed Ratios
    USACO Stringsobits
    USACO Factorials
  • 原文地址:https://www.cnblogs.com/81/p/7777162.html
Copyright © 2011-2022 走看看