Reputation: 1
I have an application and I need to always have the my.settings saved. I notice that they get cleared whenever you change the files location, or run it on a different computer. Are there any ways to prevent this. It also happens when the application updates. Thanks.
Upvotes: 0
Views: 1165
Reputation: 3843
Here is how you can retain your settings thru an upgrade:
(you also need to define a Project - Properties - Setting settings of 'ApplicationVersion' as string; you can start it off with an initial value of "not yet set")
Private Sub SetSettingsVersion()
Dim a As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim appVersion As Version = a.GetName().Version
Dim appVersionString As String = appVersion.ToString
If My.Settings.ApplicationVersion <> appVersion.ToString Then
My.Settings.Upgrade()
My.Settings.ApplicationVersion = appVersionString
End If
End Sub
Upvotes: 1