If you have VB.NET 2003, you can use the BrowseForFolder dialog to do that. Otherwise, you have to do this:
Copied from a post by :Anthony Glenwright.
In VB, create a class:
Public Class FolderBrowser
Inherits System.Windows.Forms.Design.FolderNameEditor
Private objBrowse As New
System.Windows.Forms.Design.FolderNameEditor.Folde rBrowser()
Sub New(ByVal Text As String)
MyBase.New()
objBrowse.Description = Text
End Sub
Function ShowDialog() As Windows.Forms.DialogResult
Return objBrowse.ShowDialog
End Function
Property Text() As String
Get
Return objBrowse.Description
End Get
Set(ByVal Value As String)
objBrowse.Description = Text
End Set
End Property
ReadOnly Property DirectoryPath() As String
Get
Return objBrowse.DirectoryPath
End Get
End Property
End Class
Then you can call it with:
Dim objBrowse As New FolderBrowser("Please select a folder")
If objBrowse.ShowDialog = DialogResult.OK Then
msgbox ("You picked " & objBrowse.DirectoryPath)
End If
This worked for me until I upgraded to VB.NET 2003. Then the BrowseForFolder Dialog control was added. But, this one works just
fine.
james
"Sakharam Phapale" <sp******@annetsite.com> wrote in message news:e4**************@TK2MSFTNGP09.phx.gbl...
Hi All,
I want to give option to user for selecting directory, just like for
selecting file using OpenFileDialog control.
How to make it possible?
I tried it using "VisualBasic.Compatibility.VB6.DirListBox" control, but it
does not work properly.
It has following two properties,
1.SelectedItem :- which returns just folder name.
2.Path :- which always return application path
It should return path of the selected folder, but seems to be not working.
Any solution?
Thanks in Advance
Sakharam Phapale