VB.Net: How to Persist Settings in ApplicationSettingsBase

deskcheck1-0579 411 Reputation points
2022-02-09T20:03:21.117+00:00

I have a Windows Form project that requires flexibility for users to navigate to a working directory of their own choice. I created a form settings class that inherits from ApplicationSettingsBase.

Users setup the working directory through a context menu and a folder browser dialog presents the user to navigate to their own working directory.

I save the working directory settings like this:

Private Sub SetupWorkingDirectoryToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SetupWorkingDirectoryToolStripMenuItem.Click
        Dim mySettings As New FormSettings()

        FolderBrowserDialog1.Description = "Navigate to 'APEX\WinAPEX1501' folder in your Working Directory"
        Dim result As DialogResult = FolderBrowserDialog1.ShowDialog()

        If (result = DialogResult.OK) Then
            Dim APEXPATH As String = FolderBrowserDialog1.SelectedPath            
            mySettings.WorkingDirectory = APEXPATH
            mySettings.Save()
        End If
    End Sub

How do I persist the settings so that when users exit the application and use it again later, the settings can be "recalled"?

Appreciate any help.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,903 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,166 questions
0 comments No comments
{count} votes

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.