简体   繁体   English

如何设置user.config文件的默认位置?

[英]How do I set the default location of the user.config file?

I made a project in VB.NET 2008. When I update my project I change the assembly version but the problem is that when the user gets the new version they lose their user settings. 我在VB.NET 2008中创建了一个项目。更新项目时,我更改了程序集版本,但问题是,当用户获得新版本时,他们会丢失其用户设置。

I noticed that user settings save in: 我注意到用户设置保存在:

C:\\Users\\Kalam\\AppData\\Local\\Friends'_Book_Corner\\FbcBook.exe_Url_0simcxv3dfuzhahgti5ir3txdrd4qeho\\1.0.2.9\\user.config C:\\ Users \\ Kalam \\ AppData \\ Local \\ Friends'_Book_Corner \\ FbcBook.exe_Url_0simcxv3dfuzhahgti5ir3txdrd4qeho \\ 1.0.2.9 \\ user.config

Note the version number in the path. 注意路径中的版本号。 Is there any way save in a location not affected by changing the version? 有什么方法可以保存在不受版本更改影响的位置中吗?

You can update your settings for the new assembly by calling : 您可以通过调用以下命令来更新新程序集的设置:

My.Settings.Upgrade()

This will pull values from the previous installed version of the application. 这将从先前安装的应用程序版本中提取值。 You don't want to do this accidentally and overwrite newer values with old ones so you would usually create a boolean user setting (default TRUE) to flag an update. 您不希望这样做,而是用旧值覆盖新值,因此通常会创建一个布尔用户设置(默认为TRUE)来标记更新。 When the user runs a new version they get default values and you can use this to trigger the update, setting your user update flag FALSE once it is done. 当用户运行新版本时,它们会获得默认值,您可以使用它来触发更新,并在完成后将用户更新标志设置为FALSE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM