tags:

views:

8905

answers:

8

How can I preset a control to the user that allows them to select a directory?

There doesn't seem to be any native .net controls which do this?

A: 

You could use a TreeView in combination with the DirectoryInfo class.

IceHeat
+1  A: 

It's not heavy-weight at all. Crude, yes, but it's much better than rolling your own.

Stu
+3  A: 

You could just use the FolderBrowserDialog class from System.Windows.Forms

Ch00k
A: 

How'd I miss that FolderBrowserDialog? woops :-)

Orion Edwards
+1  A: 

Please don't try and roll your own with a TreeView/DirectoryInfo class. For one thing there are many nice features you get for free (icons/right-click/networks) by using SHBrowseForFolder. For another there are a edge cases/catches you will likely not be aware of.

Andrew Grant
+1  A: 

you missed it bacause the framework is getting so big, its getting very easy to miss stuff. I'm doing it alot these days!

Damian Hickey
A: 

For much more functionality than the FolderBrowserdialog, like filtering, check-boxes, etc, take a look at 3rd party controls like Shell MegaPack. Since they are controls, so they can be put in your own forms instead of appearing as a modal dialog.

good idea if selection etc is required.
Anonymous Type