如何在C#Winforms中的app.config文件上动态更新应用程序设置键值对 [英] How to update app settings key value pair dynamically on app.config file in c# winforms

查看:65
本文介绍了如何在C#Winforms中的app.config文件上动态更新应用程序设置键值对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更新应用程序设置键,在c#winforms中的app.config文件中动态值.键,值列在下面

How to update app settings key, value dynamically on app.config file in c# winforms. Key,value are listed below

<appSettings>
    <add key="logPath" value="C:\EventLogs" />
    <add key="isScreenCaptureMode" value="false" />
    <add key="isStartOnSysStartUp" value="false" />
</appSettings>

推荐答案

Configuration configuration = ConfigurationManager.
OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
configuration.AppSettings.Settings["logPath"].Value = DateTime.Now.ToString("yyyy-MM-dd");
configuration.Save();
ConfigurationManager.RefreshSection("appSettings");

这篇关于如何在C#Winforms中的app.config文件上动态更新应用程序设置键值对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆