简体   繁体   中英

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.

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

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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