Browsing to Select a Directory in VB.NET
Dim dirDlg As New FolderBrowserDialog
dirDlg.RootFolder = Environment.SpecialFolder.MyComputer
If dirDlg.ShowDialog() = DialogResult.OK Then
' do something with the selected path
Debug.Print("Directory: " + dirDlg.SelectedPath)
Else
' the dialog was cancelled
End If
The FolderBrowsingDialog object has many options, but I have only shown the most commonly used one in the example. The RootFolder property lets you specify the directory to start browsing from. You can set this property to an explicit path (like "c:\MyData") or you can use the special directories that are defined for you:
Environment.SpecialFolder.MyDocumentThe default is Environment.SpecialFolder.MyComputer.
Environment.SpecialFolder.MyComputer
Environment.SpecialFolder.MyPictures
Environment.SpecialFolder.Desktop
After the ShowDialog call returns OK, use the SelectedPath property to get the selected directory.
1 comment:
Can you say? Which E-Book is best for to learn the .Net , Mainly for beginners?
Cegonsoft
Post a Comment