如何保存Configuation在C#的WinForms的app.config [英] How to Save Configuation in app.config in C# Winforms

查看:97
本文介绍了如何保存Configuation在C#的WinForms的app.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我如何使用 C#和WinForms?

Can someone give me an example of how to save a key/value in app.config using C# and WinForms?

推荐答案

ASP.NET 的:

Configuration config = WebConfigurationManager.OpenWebConfiguration(null);
AppSettingsSection app = config.AppSettings;
app.Settings.Add("x", "this is X");
config.Save(ConfigurationSaveMode.Modified);

的WinForms 的:

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
AppSettingsSection app = config.AppSettings;
app.Settings.Add("x", "this is X");
config.Save(ConfigurationSaveMode.Modified);

这篇关于如何保存Configuation在C#的WinForms的app.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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