Working with FolderBrowserDialog in VB.NET

First create a window application in VB.Net and add a FolderBrowserDialog controll to it. Also add a textbox(txtFolder) and button( btnBrowseFolders).

The button's work here is to open the FolderBrowserDialog and user can select any folder or file to be displayed in the text box. Now double click on the button and add the following code in it.

Private Sub btnBrowseFolders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowseFolders.Click
With fldlgList
'set the RootFolder
.RootFolder = Environment.SpecialFolder.Personal
' optional Description to provide additional instructions.
Description = "Select the directory you want to use as the default."
ShowNewFolderButton = True
'Showing the selected folder in the textbox
If ShowDialog = Windows.Forms.DialogResult.OK Then
txtFolder.Text = .SelectedPath
End If

End With

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)

End Try

End Sub


After creating a new FolderBrowserDialog, you have to set the RootFolder to the location from which to start browsing. You can choose from the list of system special folders, such as Program Files, Programs, System, or Startup, which contain common information.

RootFolder = Environment.SpecialFolder.Personal

We can give user optional information about the bowser using the Description property.

Description = "Select the directory you want to use as the default."

You can use the ShowNewFolderButton property to control if the user is able to create new folders via the New Folder button in the browse dialogue window.

ShowNewFolderButton = True


Author: Ankita_Luck08 Oct 2011 Member Level: Bronze   Points : 1

this is awesome !!!! thanks for sharing with us.
It's help me lot and also this link ...
helped me lot in completing my project.

Thanks !!!!!

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: