469,616 Members | 1,673 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,616 developers. It's quick & easy.

Open the "select folder window" in vb.net

Friends!
I need to show the dialog "select folder" and get the
path selected, using vb.net. The OpenFileDialog control
is useless as I want to select a folder and not a file.
In vb6 I achieved this by an OCX called DPDLG, but
in .net i do not find the solution neither this ocx works
in .net.

Any idea? sample code?

Thanks a lot
Pablo
Jul 19 '05 #1
2 15148
Unfortuanally nothing is included that I know of other than going back to
the SHBrowseForFolder() API. Look that up on google and it should be pretty
strait forward on how to use. Only other solution is to write one from the
ground up.

Oh check this too:
This is not my work but was listed on a google search.
http://groups.google.com/groups?hl=e...FTNGP12&rnum=6

1. You need to add a reference to "System.Design" (system.design.dll).
2. You could try this...

Imports System.Windows.Forms.Design

Public Class OpenDirectoryDialog
Inherits FolderNameEditor

Dim _Description As String = "Please select a directory below:"
Dim _Path As String = String.Empty
Dim fb As New FolderBrowser()

Public Property Description() As String
Get
Return _Description
End Get
Set(ByVal Value As String)
_Description = Value
End Set
End Property
Public ReadOnly Property Path() As String
Get
Return _Path
End Get
End Property

Public Function ShowBrowser() As System.Windows.Forms.DialogResult
With fb
.Description = _Description
.StartLocation = FolderNameEditor.FolderBrowserFolder.MyComputer
Dim result As DialogResult = .ShowDialog
If result = DialogResult.OK Then
_Path = .DirectoryPath
Else
_Path = String.Empty
End If
Return result
End With
End Function
End Class
'Usage:
Dim d As New OpenDirectoryDialog()
With d
If .ShowBrowser = DialogResult.OK Then
txtDirectory.Text = .Path
End If
End With

"Pablo" <pp******@montevideo.com.uy> wrote in message
news:0b****************************@phx.gbl...
Friends!
I need to show the dialog "select folder" and get the
path selected, using vb.net. The OpenFileDialog control
is useless as I want to select a folder and not a file.
In vb6 I achieved this by an OCX called DPDLG, but
in .net i do not find the solution neither this ocx works
in .net.

Any idea? sample code?

Thanks a lot
Pablo

Jul 19 '05 #2
Bryan,

thanks a lot for your help. It's very useful. I'll try it.

Pablo
Montevideo, Uruguay
-----Original Message-----
Unfortuanally nothing is included that I know of other than going back tothe SHBrowseForFolder() API. Look that up on google and it should be prettystrait forward on how to use. Only other solution is to write one from theground up.

Oh check this too:
This is not my work but was listed on a google search.
http://groups.google.com/groups?hl=en&lr=&ie=UTF- 8&oe=UTF-8&selm=OQieY08yCHA.2368%40TK2MSFTNGP12&rnum=6
1. You need to add a reference to "System.Design" (system.design.dll).2. You could try this...

Imports System.Windows.Forms.Design

Public Class OpenDirectoryDialog
Inherits FolderNameEditor

Dim _Description As String = "Please select a directory below:" Dim _Path As String = String.Empty
Dim fb As New FolderBrowser()

Public Property Description() As String
Get
Return _Description
End Get
Set(ByVal Value As String)
_Description = Value
End Set
End Property
Public ReadOnly Property Path() As String
Get
Return _Path
End Get
End Property

Public Function ShowBrowser() As System.Windows.Forms.DialogResult With fb
.Description = _Description
.StartLocation = FolderNameEditor.FolderBrowserFolder.MyComputer Dim result As DialogResult = .ShowDialog
If result = DialogResult.OK Then
_Path = .DirectoryPath
Else
_Path = String.Empty
End If
Return result
End With
End Function
End Class
'Usage:
Dim d As New OpenDirectoryDialog()
With d
If .ShowBrowser = DialogResult.OK Then
txtDirectory.Text = .Path
End If
End With

"Pablo" <pp******@montevideo.com.uy> wrote in message
news:0b****************************@phx.gbl...
Friends!
I need to show the dialog "select folder" and get the
path selected, using vb.net. The OpenFileDialog control
is useless as I want to select a folder and not a file.
In vb6 I achieved this by an OCX called DPDLG, but
in .net i do not find the solution neither this ocx works in .net.

Any idea? sample code?

Thanks a lot
Pablo

.

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by ian justice | last post: by
reply views Thread by Nicklas | last post: by
17 posts views Thread by haldie | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.