.NET 将配置设置保存到 PerUserRoaming 位置

发布于 2024-10-06 15:48:35 字数 1054 浏览 0 评论 0原文

我有一个带有 Settings.settings 文件的 VS2010 解决方案。用户设置保存到本地设置文件夹中,这是一个问题,因为这些设置不会漫游。

目前,设置文件自动保存到:(

Dim config_initial As System.Configuration.Configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal)
Console.WriteLine("Local user config path: {0}", config_initial.FilePath)

C:\Documents and Settings\%username%\Local Settings\Application Data\%company%\%application%.exe_Url_%hash%\%version%\user.config

有什么方法可以将此文件保存到以下文件路径:(

Dim config_new As System.Configuration.Configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoaming)
Console.WriteLine("User config path: {0}", config_new.FilePath)

C:\Documents and Settings\%username%\Application Data\%company%\%application%.exe_Url_%hash% \%version%\user.config

我只是使用 My.Settings.Save() 保存或在应用程序此时终止时自动保存。

I have a VS2010 solution with a Settings.settings file. The user settings are saved to the Local Settings folder and this is a problem as these settings do not roam.

Currently the settings file is saved automatically to:

Dim config_initial As System.Configuration.Configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal)
Console.WriteLine("Local user config path: {0}", config_initial.FilePath)

( C:\Documents and Settings\%username%\Local Settings\Application Data\%company%\%application%.exe_Url_%hash%\%version%\user.config )

Is there any way to save this file to the file path identified by:

Dim config_new As System.Configuration.Configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoaming)
Console.WriteLine("User config path: {0}", config_new.FilePath)

( C:\Documents and Settings\%username%\Application Data\%company%\%application%.exe_Url_%hash%\%version%\user.config )

I am just saving using My.Settings.Save() or automatically when the application terminates at the moment.

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

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

发布评论

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

评论(1

烟火散人牵绊 2024-10-13 15:48:36

我在此处找到了答案。在 Visual Studio 中,打开“应用程序设置”屏幕,选择单个设置,然后转到“属性”窗口。然后可以选择将 Roaming 设置为 True

在此处输入图像描述

I found the answer here. In Visual Studio, open the Application Settings screen, then select an individual setting, and then go to the Properties Window. There is then an option to set Roaming to True

enter image description here

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