Open the "select folder window" in vb.net

P

Pablo

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
 
B

Bryan Martin

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=...F-8&selm=OQieY08yCHA.2368@TK2MSFTNGP12&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
 
P

Pablo

Bryan,

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

Pablo
Montevideo, Uruguay
 
Joined
Jun 1, 2010
Messages
6
Reaction score
0
Open Outlook folder dialog and select folder using VB.NET

Following is the code sample used to display the outlook folder dialog using VB.NET


[VB.NET CODE STARTS]

Dim objOutlook As Object
Dim objOlNamespace As Object
Dim objOlFolder As Object

objOutlook = CreateObject("Outlook.Application") ' create outlook application object at the run time
objOlNamespace = objOutlook.GetNamespace("MAPI")
objOlFolder = objContactsNS.PickFolder ' displays the folder dialog

[VB.NET CODE ENDS]

http://www.mindfiresolutions.com/Open-Outlook-folder-dialog-and-select-folder-using-VBNET-896.php
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top