Click here to Skip to main content
11,430,053 members (73,429 online)
Click here to Skip to main content

Folder Browser component for .NET

, 5 Mar 2002 CPOL
Rate this:
Please Sign up or sign in to vote.
A component that provides shell folder browsing dialog to .NET applications
<!-- Download Links -->

Demo Application

Folder browser demo

Dialog generated by settings in the demo application

Folder browser demo

<!-- Add the rest of your HTML here -->

Introduction

ShellFolderBrowser is a component that makes it possible to use shell's folder browsing dialog for .NET applications. It can be used in the same way as OpenFileDialog and SaveFileDialog components which are available from the framework SDK. The component makes use of SHBrowseForFolder function and demonstrates various aspects of interoperability of managed and unmanaged code like passing delegates function pointers, passing structures and strings.

It is quite simple to use the component. You can place it on the toolbox and drag it to the form. You can set the desired properties in the component in the property grid as shown :-


Folder browser demo

In order to display the dialog all that needs to be done is to call the ShowDialog method as

folderBrowser1.ShowDialog();
		

Here is a brief description of the component. For detailed description see the documentation of SHBrowseForFolder.

Properties

BrowseFlags Sets the flags that control the behaviour of the dialog
FolderDisplayName The display name of the folder selected by the user
FolderPath The folder path that was selected
Title String that is displayed above the tree view control in the dialog box. This string can be used to specify instructions to the user. Can only be modified if the dalog is not currently displayed.

Methods

EnableOKButton Enables or disables the ok button in the dialog
SetExpanded Expand a path in the folder
SetOkButtonText Sets the text of the OK button in the dialog
SetSelection Sets the selection the text specified
SetStatusText Sets the text of the staus area of the folder dialog
ShowDialog Shows the dialog

Events

Initialized Fired when the dialog is initialized (when BFFM_INITIALIZED is send to the BrowseCallback function)
IUnknownObtained Shell provides an IUnknown through this event. For details see documentation of SHBrowseForFolder (when BFFM_INITIALIZED is send to the BrowseCallback function)
SelChanged Fired when selection changes (when BFFM_INITIALIZED is send to the BrowseCallback function)
ValidateFailed Fired when validation of text typed by user fails (when BFFM_INITIALIZED is send to the BrowseCallback function)

BrowseFlags 

BrowseFlags is an enumeration with Flags attribute set and can be a combination of any of the following values :-

ReturnOnlyFSDirs

Same as BIF_RETURNONLYFSDIRS

DontGoBelowDomain

Same as BIF_DONTGOBELOWDOMAIN

ShowStatusText

Same as BIF_STATUSTEXT

ReturnFSancestors

Same as BIF_RETURNFSANCESTORS

EditBox

Same as BIF_EDITBOX

Validate

Same as BIF_VALIDATE

NewDialogStyle

Same as BIF_NEWDIALOGSTYLE

BrowseIncludeURLs

Same as BIF_BROWSEINCLUDEURLS

AddUsageHint

Same as BIF_UAHINT

NoNewFolderButton

Same as BIF_NONEWFOLDERBUTTON

BrowseForComputer

Same as BIF_BROWSEFORCOMPUTER

BrowseForPrinter

Same as BIF_BROWSEFORPRINTER

IncludeFiles

Same as BIF_BROWSEINCLUDEFILES

ShowShareable

Same as BIF_SHAREABLE

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Rama Krishna Vavilala
Architect
United States United States
No Biography provided

Comments and Discussions

 
QuestionFolder Browser Dialog for Asp.net web applciations Pin
selllllllllllllll8-Sep-11 3:05
memberselllllllllllllll8-Sep-11 3:05 
Hi all,

If anyone have the code for the folder Browser Dialog for webbased application .Please suggest ..

Regards,
Selva.
Questioncan this use in asp.net Pin
simiabhilash11-Jun-08 0:02
membersimiabhilash11-Jun-08 0:02 
AnswerRe: can this use in asp.net Pin
bibiboule10-Feb-09 4:39
memberbibiboule10-Feb-09 4:39 
QuestionHow to hide the Network Folder? Pin
gust08315-Nov-07 10:25
membergust08315-Nov-07 10:25 
AnswerRe: How to hide the Network Folder? Pin
jmcc2k10-Nov-08 22:31
memberjmcc2k10-Nov-08 22:31 
GeneralFolder Browser on framework 1.1 Pin
ncremaschini2-Oct-07 1:30
memberncremaschini2-Oct-07 1:30 
GeneralAdd to the list Pin
matt_davis23-May-07 10:09
membermatt_davis23-May-07 10:09 
QuestionFolder Browser Dialog Pin
Vikram Tapikar2-Mar-06 1:40
memberVikram Tapikar2-Mar-06 1:40 
AnswerRe: Folder Browser Dialog Pin
matt_davis31-May-07 10:02
membermatt_davis31-May-07 10:02 
GeneralFolder Browser in Web Project Pin
Jeevan The Wonder23-Feb-06 0:50
memberJeevan The Wonder23-Feb-06 0:50 
GeneralRe: Folder Browser in Web Project Pin
Rama Krishna Vavilala23-Feb-06 1:45
memberRama Krishna Vavilala23-Feb-06 1:45 
GeneralRe: Folder Browser in Web Project Pin
selllllllllllllll8-Sep-11 3:03
memberselllllllllllllll8-Sep-11 3:03 
GeneralFolder Browser Component Pin
mjwaller1-Feb-06 9:14
membermjwaller1-Feb-06 9:14 
GeneralThis code sucks Pin
Tom Guinther21-Jan-06 10:08
memberTom Guinther21-Jan-06 10:08 
GeneralRe: This code sucks Pin
Rama Krishna Vavilala21-Jan-06 15:55
memberRama Krishna Vavilala21-Jan-06 15:55 
QuestionWhat is the sense of the NoNewButtonFolder flag? Pin
Josef Meile12-Jan-06 8:57
memberJosef Meile12-Jan-06 8:57 
AnswerRe: What is the sense of the NoNewButtonFolder flag? Pin
Josef Meile12-Jan-06 9:07
memberJosef Meile12-Jan-06 9:07 
GeneralShellbrowserDialog Textbox Pin
MohanPazhanganattu10-Jan-06 21:45
memberMohanPazhanganattu10-Jan-06 21:45 
GeneralButton Text/Title Not Visible Pin
Alaranaz11-Dec-05 18:33
memberAlaranaz11-Dec-05 18:33 
GeneralA fix for SetSelection() Pin
lujason17-Dec-05 11:31
memberlujason17-Dec-05 11:31 
AnswerBest Solution: Use OpenFileDialog Pin
softplanner6-Dec-05 6:14
membersoftplanner6-Dec-05 6:14 
GeneralRe: Best Solution: Use OpenFileDialog Pin
Ineffable1-Aug-06 9:47
memberIneffable1-Aug-06 9:47 
GeneralRe: Best Solution: Use OpenFileDialog Pin
Hamid Qureshi19-Sep-06 2:25
memberHamid Qureshi19-Sep-06 2:25 
GeneralRe: Best Solution: Use OpenFileDialog Pin
sergio treiger16-May-09 9:38
membersergio treiger16-May-09 9:38 
GeneralRe: Best Solution: Use OpenFileDialog Pin
sergio treiger16-May-09 9:51
membersergio treiger16-May-09 9:51 
Questionhow does it work ? Pin
quietcoder8-Sep-05 7:51
memberquietcoder8-Sep-05 7:51 
GeneralOK button text Pin
HStrix2-Mar-05 0:51
memberHStrix2-Mar-05 0:51 
GeneralRe: OK button text Pin
HStrix2-Mar-05 20:13
memberHStrix2-Mar-05 20:13 
GeneralYou forget something Pin
Yaron Sh8-Feb-05 22:33
memberYaron Sh8-Feb-05 22:33 
GeneralFew suggestions Pin
smallguy7824-Nov-04 2:07
membersmallguy7824-Nov-04 2:07 
GeneralListing names of files in a folder in C# Pin
Anonymous2-Aug-04 11:08
sussAnonymous2-Aug-04 11:08 
Questionsame thing in vb.net? Pin
Bose02119-Apr-04 15:23
sussBose02119-Apr-04 15:23 
GeneralAn Expert Joker Pin
Anonymous9-Apr-04 1:11
sussAnonymous9-Apr-04 1:11 
GeneralBrowseForComputer Pin
Grim1223-Jul-03 6:38
memberGrim1223-Jul-03 6:38 
QuestionReturn ComputerName? Pin
Anonymous1-Jul-03 6:27
sussAnonymous1-Jul-03 6:27 
GeneralNewDialogStyle doesnt do anything Pin
Umair Ahmad19-Mar-03 23:47
memberUmair Ahmad19-Mar-03 23:47 
GeneralInitial folder Pin
Mazdak8-Mar-03 6:28
memberMazdak8-Mar-03 6:28 
GeneralCan't select folder Pin
marcusquigley23-Nov-02 12:04
membermarcusquigley23-Nov-02 12:04 
GeneralThanks Pin
Mazdak27-Aug-02 11:16
memberMazdak27-Aug-02 11:16 
GeneralRe: Thanks Pin
David Stone27-Aug-02 13:08
memberDavid Stone27-Aug-02 13:08 
GeneralRe: Thanks Pin
Code Monkey7-Oct-02 1:09
memberCode Monkey7-Oct-02 1:09 
QuestionAn alternate way? Pin
Bill Harper1-Aug-02 10:44
sussBill Harper1-Aug-02 10:44 
AnswerBest Way Pin
Rama Krishna9-Aug-02 16:19
memberRama Krishna9-Aug-02 16:19 
GeneralThings that make you go hmmm. Pin
Anonymous26-Jul-02 5:59
sussAnonymous26-Jul-02 5:59 
GeneralJust what I needed! Pin
Martin 'Lucanus cervus'29-Jun-02 23:09
memberMartin 'Lucanus cervus'29-Jun-02 23:09 
GeneralRe: Just what I needed! Pin
Rama Krishna8-Jul-02 8:17
memberRama Krishna8-Jul-02 8:17 
GeneralSetting the initial folder Pin
mhenry138429-Apr-02 17:33
membermhenry138429-Apr-02 17:33 
GeneralRe: Setting the initial folder Pin
JDutch2-Jul-02 6:04
memberJDutch2-Jul-02 6:04 
GeneralRe: Setting the initial folder Pin
mhenry13848-Jul-02 8:08
membermhenry13848-Jul-02 8:08 
GeneralRe: Setting the initial folder Pin
Anonymous24-Jul-02 1:57
sussAnonymous24-Jul-02 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150428.2 | Last Updated 6 Mar 2002
Article Copyright 2002 by Rama Krishna Vavilala
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid