zoukankan      html  css  js  c++  java
  • C# 从配置文件中读取/写入信息

    读取:

     var currMemberID = System.Configuration.ConfigurationManager.AppSettings["tolunaMemberID"]; //currMemberID = 8000015

    Web.Config文件:

    <appSettings>
    <add key="tolunaMemberID" value="8000015" />
    </appSettings>

    写入:

    Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");//读取配置文件
    config.AppSettings.Settings.Remove("tolunaMemberID");//移除该字段
    config.AppSettings.Settings.Add("tolunaMemberID", “8000020”);//新添加字段并设置
    config.Save();//保存

    Web.Config文件:

    <appSettings>
    <add key="tolunaMemberID" value="8000020" />
    </appSettings>

  • 相关阅读:
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    Oil Skimming HDU
    Rain on your Parade HDU
    Swap HDU
    棋盘游戏 HDU
  • 原文地址:https://www.cnblogs.com/DidiLiu/p/10173167.html
Copyright © 2011-2022 走看看