Folder Browser Dialog (VB.NET)

OverviewFolder Browser Dialog

Folder Browser Dialog is Microsoft .Net component. You can find this component in the toolbox under the dialogs tab. This dialog is normally used to browse the folders or to locate a path for the later use in the program, like to set data file reading and writing path. The dialog has not much customization except you can allow or disallow the user to create the new folder. in the appearance of the dialog you can add few words in the Description property, which appears on the top of the dialog.

There are two more buttons on the layout of dialog, Ok button and Cancel button, both buttons has the same function, which is defined through out in the windows environment. After selecting the desired folder user clicks the Ok button and the path is returned in the SelectedPath property that you can use in your program.


This dialog has not much properties. The normally used properties and their usage is explained below.

  • Description
  • SelectedPath
  • RootFolder
  • ShowNewFolderButton

Description Property

This property is used to give descriptive detail for which the dialog is being displayed. for example if you are displaying this dialog box for setting the root folder for your application data file, preferences file, cookies, etc.

Example Code

  Dim FolderBrowser As New FolderBrowserDialog

        FolderBrowser.Description = "Hello this my description for this dialog. You can write your own here."




SelectedPath Property

This property is read/write property. This property returns the selected path in response, when OK button is clicked, otherwise it returns the empty string. if you set this property with any valid path before calling the ShowDialog method, it will take you directly to that folder location.

Example Code

  Dim FolderBrowser As New FolderBrowserDialog

        If FolderBrowser.ShowDialog = Windows.Forms.DialogResult.OK Then
  MsgBox("You have canceld the dialog.")
        End If



RootFolder Property

This property is read/write, It can set the default root for user, defined in the system special folders. It accepts the Special Folder as a property value. The SpecialFolder is enumerator constants defined in the Environment class. Default value is zero which represents the Desktop. You can get further reference for special folder enumerator constants here

Example Code

  Dim FolderBrowser As New FolderBrowserDialog
        FolderBrowser.RootFolder = Environment.SpecialFolder.MyMusic


ShowNewFolderButton Property

This property enables or disables the make new folder button on the dialog layout. This way you can restrict the user from creating the new folder in the root or in sub folders. Default value for this property is True.

Example Code

  Dim FolderBrowser As New FolderBrowserDialog
        FolderBrowser.ShowNewFolderButton = False



This dialog has only one significant method ShowDialog. it invokes the FolderBrowser object as Modal dialog and displays on the screen. It returns the dialog enumerator constant as dialog result. for its example code see above examples.


Download source code here


About ezonemag
A Webmaster Thats All

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: