views:

502

answers:

3

Using C# and WinForms in VS2008, I want to create a file browser control that looks and acts like the left pane in Windows Explorer. To my astonishment, such a control does not ship with .NET by default.

Ideally, I would like its contents to be exactly the same as in Explorer. For example, on Windows 7, it should show the Favorites and Libraries pseudo-folders. Of course, I do not want to code specifically for each version of Windows if I can help it.

I have browsed around, and there are some examples of such controls, but they are all hand-rolled and therefore won't work 100% the same as the one in Explorer.

Is there any way I can simply reuse the Explorer control instead? Or, if not, to get access to a tree of the items that it would show?

A: 

It's not as easy as it seems to implement a control like that. Explorer works with shell items, not filesystem items (ex: the control panel, the printers folder, and so on). If you need to implement it i suggest to have a look at the Windows shell functions at http://msdn.microsoft.com/en-us/library/bb776426(VS.85).aspx.

munissor
"It's not as easy as it seems to implement a control like that." I realize that. Which is exactly why I would prefer not to reinvent the wheel.
Thomas
A: 

Microsoft provides a walkthrough for creating a Windows Explorer style interface in C#.

There are also several examples on Code Project and other sites. Immediate examples are Explorer Tree, My Explorer, File Browser and Advanced File Explorer but there are others. Explorer Tree seems to look the best from the brief glance I took.

I used the search term windows explorer tree view C# in Google to find these links.

Jeff Yates
Again, those are reinventing the wheel, and bound to get it wrong in various corner cases. But I'm accepting this because you provided the largest number of useful links.
Thomas
@Thomas: It think re-inventing the wheel is the only option you have as Windows doesn't expose that control for use outside of Explorer.
Jeff Yates
A: 

Take a look at Shell MegaPack control set. It provides Windows Explorer like folder/file browsing with most of the features and functionality like context menus, renaming, drag-drop, icons, overlay icons, thumbnails, etc

logicnp
I had already run into that. If this weren't my first commercial application, I'd happily pay those $299, but as it stands, I can't afford that.
Thomas