c# - 如何更改运行时应用程序设置

标签 c# .net settings.settings

我试图在运行时更改我的应用程序设置文件的一个键,但它不起作用。

我就是这样做的:

ConfigurationSettings.AppSettings["XPTO"] = "HELLO";

貌似只在内存里变,文件上没变。

有人知道怎么做吗?

谢谢。

最佳答案

看看我的overview of .NET settings files ...简而言之,我认为您需要一个用户范围的设置。它的行为将更符合您的预期。

Edit: If you are using the settings designer in Visual Studio, then simply change the "Scope" to "User". If not, you should be able to do the equivalent programmatically.

关于c# - 如何更改运行时应用程序设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/546229/

相关文章:

c# - 如何使用 WebAPI 返回 Dictionary<complexType,int>

c# - datagridview 组合框单元格 c#

c# - 获取Windows任务栏中当前可见的应用程序(或Windows)列表

c# - 在 settings.settings 中添加自定义类型

c# - <userSettings> 在 app.config 中找不到元素 'userSettings' 的架构信息

c# - 无法在服务结构中使用 DNS 与服务通信

c# - 指数进度报告

c# - .Net 在编译时将类常量设置为其命名空间

.net - Image.FromStream : Parameter not valid

winforms - 当我在 C++ Windows 窗体应用程序中添加 .settings 文件时,Visual Studio 崩溃