views:

121

answers:

1

I need some kind of dialog for browsing the local SMB network for file shares. VBScript does it like this.

Set application = CreateObject("Shell.Application")
Set folder = application.BrowseForFolder(0, "Moo!", &h250, &h12) ' &h12 sets
' Network as the root folder.

So I added a reference to Forms and tried to do it with FolderBrowserDialog, but to my surprise:

FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.RootFolder = /* The Environment.SpecialFolder enumeration doesn't have
a value Network! */
dialog.RootFolder = (Environment.SpecialFolder)0x12; /* This dirty trick doesn't
work too. */

Then I looked for a pinvokable function in the Windows API that does this, but didn't find any.

+1  A: 

The native Windows function is SHBrowseForFolder but under .NET you should use the FolderBrowserDialog class

Shay Erlichmen