如何在运行时应用程序的设置更改时应、程序、如何在

2023-09-03 06:00:22 作者:述说的你的心情。

我想在运行时改变我的应用程序的设置文件的一个重点,但它不能正常工作。

I'm trying to change in runtime one key of my applications settings file, but it does not work.

我做这样:

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

它似乎只改变内存,而不是在文件中。

It seems that it only changes in memory, not on the file.

有谁知道如何做到这一点?

Does anyone knows how to do this?

感谢。

推荐答案

看看我的overview .NET程序的设置文件 ......总之,我想你想一个用户范围设置。它会表现得更像你期望的那样。

Take a look at my overview of .NET settings files...In short, I think you want a user-scoped setting. It will behave more like you expect.

编辑:如果您使用的是设置设计师在Visual Studio ,则只需更改范围为用户。如果没有,你应该能够以编程方式做等价。

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.