如何在 C# Winforms 中保存 app.config 中的配置 [英] How to Save Configuation in app.config in C# Winforms
本文介绍了如何在 C# Winforms 中保存 app.config 中的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能给我一个例子,说明如何使用 C#
和 WinForms 在 app.config 中保存键/值?
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);
这篇关于如何在 C# Winforms 中保存 app.config 中的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文