Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net set specific folderfor FolderBrowserDialog

Hi

How do I set a custom or specific RootFolder for the FolderBrowserDialog1. I want to specify a very specific location
held in a text variable.

Thanks
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Avatar of Murray Brown

ASKER

Thanks Eric, but I had worked out the .SelectedPath file part. I know that the following line is incorrect but I want to be able to set the RootFolder to a specific path
dialog.RootFolder = "C:Program Files"
I need to set the RootFolder to this before the user makes any selection
Or am I missing something
to which path do you want the dialog to open?
a backslash is missing:
        Dim dialog As New FolderBrowserDialog
        dialog.RootFolder = Environment.SpecialFolder.Desktop
        dialog.SelectedPath = "C:\Program Files"
        If (dialog.ShowDialog() = DialogResult.OK) Then
            MessageBox.Show(dialog.SelectedPath)
        End If

Open in new window

I want the dialog to open at the root folder. If you specify the .SelectedPath you often have to scroll down to see that it is selected whereas the RootFolder will automatically scroll down. In my program the RootFolder needs to be able to be any path, not just the special options you get.
and what is your root folder set at?
The folder path held in a string could be anything so I don't set the root folder to any of the given options
As an example I want my root folder to be "C:\Users\murbr\Dropbox\Lesedi Automations\Automator"

If I specify FoldBrowserDialog1.SelectedPath = "C:\Users\murbr\Dropbox\Lesedi Automations\Automator"
 I see the following

User generated image
I then have to scroll down to see

User generated image
I don't want the user to have to scroll down. I want it to be obvious to them that they are at that location. The root folder would do this but I don't know how to set it to to
 "C:\Users\murbr\Dropbox\Lesedi Automations\Automator"
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks very much Eric. Great answer! Worked perfectly.