How to create an Explorer-like folder browser control?

104,391

Solution 1

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.

Solution 2

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.

Share:
104,391
Keyur Padalia
Author by

Keyur Padalia

Indie game developer, making games under the name Frozen Fractal. Also doing remote freelance work. Before that, I worked as a Software Engineer at Google Munich, and as a Site Reliability Engineer at Google London. I studied Computing Science in Groningen, The Netherlands. I am experienced in C, C++, C#, Java, Kotlin, JavaScript and Python and have some experience with PHP, Perl, Ruby and Haskell, among others. I am also the author of Taekwindow, a Windows utility that enables Alt+drag style moving and resizing of windows, common in many X11 window managers.

Updated on March 11, 2020

Comments

  • Keyur Padalia
    Keyur Padalia about 4 years

    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?

  • Keyur Padalia
    Keyur Padalia about 14 years
    "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.
  • Keyur Padalia
    Keyur Padalia about 14 years
    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.
  • Keyur Padalia
    Keyur Padalia about 14 years
    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.
  • Jeff Yates
    Jeff Yates about 14 years
    @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.