.NET 将配置设置保存到 PerUserRoaming 位置
我有一个带有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在此处找到了答案。在 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
toTrue