Category: VB.NET
Hits: 106

FolderBrowserDialog Box in VB.NET

Step 1: Create a new project and form

Step 2: Add a TextBox, Button and FolderBrowserDialog to the form.

Step 3: Double click btnBrowse, and key in the following codes.

Private Sub btnBrowse_Click(sender As Object, e As EventArgs) Handles btnBrowse.Click
     Dim folderDlg As New FolderBrowserDialog
     folderDlg.ShowNewFolderButton = True
     If (folderDlg.ShowDialog() = DialogResult.OK) Then
          txtDir.Text = folderDlg.SelectedPath
          Dim root As Environment.SpecialFolder = folderDlg.RootFolder
     End If
End Sub

Step 4: Run the project.