Open the "select folder window" in vb.net

  • Thread starter Thread starter Pablo
  • Start date Start date
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
 
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
 
Bryan,

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

Pablo
Montevideo, Uruguay
 
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
 
Back
Top