Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an Explorer-like folder browser control?

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?

like image 772
Thomas Avatar asked Mar 10 '10 12:03

Thomas


People also ask

How do I create my own File Explorer?

Right-click a folder in Explorer and select Properties. Then select the Customize tab shown directly below. Press the Change Icon button. Choose an alternative icon for the folder from the System32 folder.

What is folder browser dialog?

A FolderBrowserDialog control is used to browse and select a folder on a computer. A typical FolderBrowserDialog looks like Figure 1 where you can see Windows Explorer-like features to navigate through folders and select a folder.

Where is File Explorer options in Control Panel?

Open Control Panel > Small Icons View and click on the File Explorer Options applet.


2 Answers

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.

like image 158
Jeff Yates Avatar answered Sep 22 '22 07:09

Jeff Yates


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.

like image 35
munissor Avatar answered Sep 23 '22 07:09

munissor