class Program
{
static void Main(string[] args)
{
string name = ConfigurationManager.AppSettings["NAME"].ToString();
int age = int.Parse(ConfigurationManager.AppSettings["AGE"]);
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["NAME"].Value = "YourName";
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings"); // 重新加载新的配置文件
}
}
App.config文件读写
最新推荐文章于 2024-07-17 19:41:20 发布