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
Try
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 SubDESCRIPTION:-
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
Hi,
this is awesome !!!! thanks for sharing with us.
It's help me lot and also this link ...
mindstick.com/Articles/463c11c3-4360-4797-91da-506843dc0dd6/?FolderBrowserDialog%20Control%20in%20VB.Net
helped me lot in completing my project.
Thanks !!!!!