Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

HOWTO: make an openFileDialog select folder? not a file

0 views
Skip to first unread message

_st0rm_

unread,
Dec 8, 2002, 8:50:37 AM12/8/02
to
My program works with folders and I want to make a dialog
which will help the user to select the active folder. How
can I make such adialog?

Thomas Scheidegger [MVP] NETMaster

unread,
Dec 8, 2002, 10:34:11 AM12/8/02
to
In .NET 1.0 only with PInvoke to SHBrowseForFolder :
http://support.microsoft.com/?kbid=306285

http://www.codeproject.com/cs/miscctrl/folderbrowser.asp

or some people use the internal FolderNameEditor:
http://groups.google.com/groups?selm=q0JKzDbmCHA.2144%40cpmsftngxa09


And .NET 1.1 has new class:
System.Windows.Forms.FolderBrowserDialog


--
Thomas Scheidegger - MVP .NET - 'NETMaster'
http://www.cetus-links.org/oo_dotnet.html - http://dnetmaster.net/


William LaMartin

unread,
Dec 10, 2002, 9:01:39 AM12/10/02
to
Here is some code for a directory browser that I found on one of these
newsgroups awhile back. Don't recall the submitter. Note that you need a
reference to system.design.dll

Public Class DirBrowser

'need a reference to system.design.dll to make the line below work

Inherits System.Windows.Forms.Design.FolderNameEditor
Private m_Description As String = "Choose a Directory..."
Private m_ReturnPath As String = ""
Private fb As FolderBrowser = New FolderBrowser()

Public WriteOnly Property Description()
Set(ByVal Value)
m_Description = Value
End Set
End Property

Public ReadOnly Property ReturnPath() As String
Get
Return m_ReturnPath
End Get
End Property

Public Function ShowDialog() As DialogResult
fb.Description = m_Description
fb.StartLocation = FolderBrowserFolder.MyComputer

Dim r As DialogResult = fb.ShowDialog

If r = DialogResult.OK Then
m_ReturnPath = fb.DirectoryPath
Else
m_ReturnPath = ""
End If

Return r

End Function
End Class

"_st0rm_" <_st0...@mail.ru> wrote in message
news:04c801c29ec0$c9dd53f0$d2f82ecf@TK2MSFTNGXA09...

0 new messages