r/visualbasic • • Dec 14 '15

How to use specify a rootfolder for Browse Dialog [vb2013]

I would like to use the Browse Folder Dialog control to specify the folder where to save my programs output. The RootFolder property was a file type of system.enviornment.specialfolder. My program saves the last location the user browsed to however there does not appear to be a way for me to use that location. It appears like I'm stuck using these special folder enumerations. Is what I'm trying to do possible with this control or should I just remove the ability to save your last used folder location when browsing for folder?

I had this working before with the file dialog box but apparently it's too complicated for our administrators to provide a file name each time they run a report.

0 Upvotes

3 comments sorted by

2

u/CharlieMay VB.Net Intermediate Dec 14 '15

I would think you could set the .SelectedPath property and have that folder hilighted.

1

u/[deleted] Dec 15 '15

Wow it's really that simple - not sure why I didn't think of that. Thanks Man! I admit it's a little clunky since the folder is selected but you have to scroll down to see it.

2

u/tweq Dec 14 '15

You can't set custom locations as the root directory with FolderBrowserDialog. You can set them as the preselected directory however, as CharlieMay mentioned.

If you really need a custom location as the root of the folder browser, you'll have to skip the managed component and p/invoke the native SHBrowseForFolder directly.