Is there OpenFolderDialog?

  • Thread starter Thread starter Noor Saifi
  • Start date Start date
N

Noor Saifi

I want the user to select a folder from the machine
through a FileOpenDialog kind of interface.

Is there any way so that i can ask the user to select a
folder instead of File?

Thanx and Regards,

Noor
 
Hi,

There seems to be no managed component for this dialog, so you'll have to do
COM Interop to the Shell objects contained in shell32.dll,
Shell.BrowseForFolder to be exact.
 
As far as I know, you need to use the SHBrowseForFolder
Win32 API function (I think I read somewhere that the
Framework 1.1 provides this, but I'm not entirely sure as
I'm using 1.0). There's a pretty good explanation and
source code (in C#) at:

www.microbion.co.uk/developers/csharp/brwsfold.htm

There's also lots of places online that have pre-made
components to use this API in different development
languages. Just search for SHBrowseForFolder and you
should find something.

Paul K
 
Noor,

There is a managed component for that very purpose. It is only
supported in version 1.1 of the .NET Framework. It is
System.Windows.Forms.FolderBrowserDialog. According to the MSDN:

This class provides a way to prompt the user to browse, create, and
eventually select a folder. Use this class when you only want to allow the
user to select folders, not files.

Hope this helps,

Jason Coon
 
Back
Top