Store and Retrieve last selected path of FolderBrowserDialog in app.config file

Add the following key value setting under appSettings Section in app.config file.


       <add key=”LastOpenedfolderPath” value=”D:\MyXyzFolder” />


VB.Net Code to Retrieve and Store the latest one:

Dim folderDlg As New FolderBrowserDialog

Retrieving From config file. If there is wrong path was stored in config file, it will open the default Root folder.
folderDlg.SelectedPath = ConfigurationManager.AppSettings(“LastOpenedfolderPath“).ToString()

If (folderDlg.ShowDialog() = DialogResult.OK) Then
Storing the Last opened Folder in Config File
Dim objConfig As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
objConfig.AppSettings.Settings(“LastOpenedfolderPath“).Value = folderDlg.SelectedPath
End If

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: