<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="K" value="V" />
</appSettings>
</configuration>
2、添加引用
先在工程里添加system.configuration.dll程序集的引用
using System.Configuration;
3、读
string myvalue = ConfigurationManager.AppSettings["K"];
4、写
Configuration cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
cfg.AppSettings.Settings["K"].Value = "自定义值";
cfg.Save();
ConfigurationManager.RefreshSection("appSettings");
转:http://greatverve.cnblogs.com/archive/2011/07/18/app-config.html