How to Create an Explorer-Like Folder Browser Control

How to create an Explorer-like folder browser control?

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.

Folder browser dialog like open file dialog

It is something similar in Office, a dialog which allows to select a folder.
The only difference is that the Select folder button is named "OK" instead of "Select folder".

Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Core.FileDialog fileDialog = app.get_FileDialog(Microsoft.Office.Core.MsoFileDialogType.msoFileDialogFolderPicker);
fileDialog.InitialFileName = "c:\\Temp\\"; //something you want
int nres = fileDialog.Show();
if (nres == -1) //ok
{
Microsoft.Office.Core.FileDialogSelectedItems selectedItems = fileDialog.SelectedItems;

string[] selectedFolders = selectedItems.Cast<string>().ToArray();

if (selectedFolders.Length > 0)
{
string selectedFolder = selectedFolders[0];
}
}

Of course, you need to add references to Microsoft.Office.Core (Microsoft Office 14.0 Object Library) and Microsoft.Office.Interop.Excel (Microsoft Excel 14.0 Object Library).

Embedding a File Explorer instance in a Windows Forms application form

In order to handle renaming, deleting and make other customization you need to write your own file explorer. WebBrowser control is not suitable for your needs. It's just a wrapper over ActiveX component.

You should check this codeproject article. It contains an implementation of file explorer. There are few more samples of file browser:

one

two

opening Directories like in windows explorer on windows form?

There are a number of articles on codeproject.com showing how to create a Windows Explorer like UI using standard Winform controls. These look promising:

Windows Explorer in C#

A Windows Explorer in a user control

There are others though.

I'd start with one of these and modify to suit your needs.



Related Topics



Leave a reply



Submit