How to get FolderBrowserDialog to start at the program's location?

Sumo

Member
Joined
Jun 14, 2005
Messages
10
Programming Experience
Beginner
How to get FolderBrowserDialog to start at the program's location? --RESOLVED--

I am using the FolderBrowserDialog to allow the user to choose a folder for activity. The folder will most likely be a subfolder of where the program is running. How can I specify that when the user opens the FBD it is already drilled into the folder where the app is?

TIA!
 
Last edited:
You will have to do it in code, rather than the designer, because you won't actually know the program's location until run-time. Use this code:
VB.NET:
Me.FolderBrowserDialog1.SelectedPath = Application.StartupPath
You can also set the RootFolder property to prevent access to folders above a certain point.

Note that every class in the .NET Framework has a member listing in the help. Simply type "FolderBrowserDialog Members", for example, into a help search and one of the first, if not THE first, result will be the member listing for that class. A quick look through this will very often tell you exactly what you are after. Each member, be it property or method or otherwise, has a brief description and a link to a more comprehensive explanation.

Edit:
You can also put your cursor on the name in code and press F1 to get the member listing. Not sure why I didn't say this before.
 
Last edited:
OK, thanks! I had, of course, checked through the Member listing and read up on this control. The part I was missing was the part about setting it in code in the Load event rather than in the designer.

Works like a champ, thanks gents!
 
Back
Top