写入后重新加载app.config

发布于 2024-09-02 20:10:35 字数 368 浏览 3 评论 0原文

当我使用它写入我的 app.config 文件时:

Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["Wachtwoord"].Value = "Test";
config.Save();
ConfigurationManager.RefreshSection("appSettings");

我可以再次读取它。但是当我关闭并重新启动程序时,“Wachtwoord”的值再次更改为旧值。

有人知道我该如何解决这个问题吗?

谢谢

When I use this to write to my app.config file:

Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["Wachtwoord"].Value = "Test";
config.Save();
ConfigurationManager.RefreshSection("appSettings");

I can read it again. But when i close and restart the program, the value of "Wachtwoord" has changed again to the old value.

Does anybody how I could fix this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沧桑㈠ 2024-09-09 20:10:35

您确定这不是由 Visual Studio 在构建项目时覆盖您的设置文件引起的吗?原始设置文件与源代码一起存在,而您从构建输出目录(例如 bin\debug)运行应用程序。运行应用程序时,您可能会更改构建输出目录中的副本,这将更改那里的版本。当您重建项目时,设置文件将被覆盖。

Are you sure that this has not been caused by Visual Studio overwriting your settings file when you build the project? The original settings file lives with your source code, whereas you run the application from your build output directory (e.g. bin\debug). You may be making changes to the copy in the build output directory when you run the application, which will make changes to the version there. When you rebuild the project, the settings file will be overwritten.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文