Forum guidelines
AuthorQuestion
FolderBrowserDialog (how to use..?)
Posted By recca hanabishi on 10 Apr 2006
hi to all,

...im new to VB.net and i would just wanna ask on how to use the FolderBrowserDialog or anybody can show a snippet on how to do so on browsing the folders..

Thanx

-iceblizzard-

--winter world of iceblizzard
AuthorReply
Re: FolderBrowserDialog (how to use..?)
Posted By Bhasker Das on 11 Apr 2006  
Hi Iceblizzard
Its pretty simple, Create a new windows application, drag and drop FolderBrowserDialog control from toolbox, Probable its id will be "folderBrowseDialog1". Now add a button control and text box control to your form (just drag and drop). You can change their name too (As i changed their name to "btnClick" and "txtBrowseText". Now i am giving you a sample 2 line C# code on button click.

folderBrowserDialog1.ShowDialog();
txtBrowseText.Text = folderBrowserDialog1.SelectedPath;

Change this C# Code to your VB.NET. Now when you will click to button, it will open folder browser control and you can select your desired folder. After clicking ok text box will show the selected path by folder browser dialog control.

Feel free to ask more ...


Sam
  • 0
  • 0
Re: FolderBrowserDialog (how to use..?)
Posted By Sam on 30 Jul 2009  
Thanks man. Super easy, very helpful on getting the ball rolling!
Re: FolderBrowserDialog (how to use..?)
Posted By Kirtan Patel on 31 Jul 2009  
FolderBrowseDialog fd  = new FolderlBrowseDialog();

if ( fd.ShowDialog() == Dialog.Result.Ok)
{


string selectedFolder = fd.SelectedPath;
//Do Something



}

MY BLOG ( www.codestructs.com ) | MY SITE

Kirtan
 Patel   BCA   MCA (SEMESTER-IV)  MINDCRACKER MVP WEB HACKER



Re: FolderBrowserDialog (how to use..?)
Posted By xuxiang lin on 22 Feb 2010  
thx, that is really useful

hihi
Re: FolderBrowserDialog (how to use..?)
Posted By Stulie on 14 Apr 2010  
I am trying to code so that my root folder shows if the user chooses cancel but I can't seem to figure it out.  Any assistance?  My code is below.

  Dim dlgSetFolderLocation As New FolderBrowserDialog



        ' User instructions.
        dlgSetFolderLocation.Description = "Please select a folder for the download."



        ' Disable NewFolder option.
        dlgSetFolderLocation.ShowNewFolderButton = False



        ' Set root folder where user starts browsing.
        dlgSetFolderLocation.RootFolder = Environment.SpecialFolder.Desktop

        ' Path user selects.
        dlgSetFolderLocation.SelectedPath = My.Computer.FileSystem.SpecialDirectories.Desktop



        ' If the user clicks OK button..
        If dlgSetFolderLocation.ShowDialog = DialogResult.OK Then

            ' Show user path in lblFolderLocation
            Me.lblFolderLocation.Text = dlgSetFolderLocation.SelectedPath
        Else
            ' If user selects cancel, show root path in lblFolderLocation

        End If
    End Sub

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.