-
My.Settings problems
1. I can't find the file which reflects changes to user settings. This might be because I just can't find it (I can see a bunch of user.config files but they are all empty - weird!), or ...
2. I'm not actually saving them when I think I am.
Regarding 2. - do I need to invoke
immediately after every change that is made to the settings , or can I just rely on the settings being saved automatically when the application ends?
I have this code in Settings.Designer.vb :-
Code:
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
Is this all I need? And if so, why are my user.configs empty?
-
Re: My.Settings problems
By default, settings are automatically saved when the application exits. It's only if you uncheck that option in the project properties that you need save explicitly. Some people like to save explicitly after a change anyway, in case the application doesn't exit properly. If you handle the UnhandledException event of the application, the only reason that might happen is a power failure.
I'm not sure what you're doing wrong but I just created a test app with a String setting and an Integer setting, ran it, changed the values and then closed it. I then clicked the Synchronize button I mentioned to get the user config file path. When I navigated to that location, I found the new values. I suggest that you do the same, i.e. create a test project and add nothing other than a couple of settings and some code to the form's Load event handler to change them.