views:

4112

answers:

5

In a C# .NET 3.5 app (a mix of WinForms and WPF) I want to let the user select a folder to import a load of data from. At the moment, it's using System.Windows.Forms.FolderBrowserDialog but that's a bit lame. Mainly because you can't type the path into it (so you need to map a network drive, instead of typing a UNC path).

I'd like something more like the System.Windows.Forms.OpenFileDialog, but for folders instead of files.

What can I use instead? A WinForms or WPF solution is fine, but I'd prefer not to PInvoke into the Windows API if I can avoid it.

+1  A: 

Unfortunately there are no dialogs other than FolderBrowserDialog for folder selection. You need to create this dialog yourself or use PInvoke.

aku
A: 

There is a quite similar question posted on SO earlier on..

Espenhh
A: 

So far, based on the lack of responses to my identical question, I'd assume the answer is to roll your own dialog from scratch.

I've seen things here and there about subclassing the common dialogs from VB6 and I think this might be part of the solution, but I've never seen anything about modifying what the dialog thinks it's selecting. It'd be possible through .NET via PInvoke and some other tricks, but I have yet to see code that does it.

I know it's possible and it's not Vista-specific because Visual Studio has done it since VS 2003.

Here's hoping someone answers either yours or mine!

OwenP
A: 

Visual Studio has 'rolled its own' and is not using the system dialogs.

Rolling your own is not at all trivial. Depending on whether you are willing to shell out, you may want to opt for 3rd party controls such as Shell MegaPack. The controls from Shell MegaPack can be made to behave in any way you want, including making them pick folders, adding additional/custom controls such as 'preview' box, etc

+6  A: 
Cheeso
Ahhhh! Bright pink! My eyes... my poor eyes...
dthrasher
my daughter did that...
Cheeso
Isn't that the usual excuse? ;-)
Joey