-1

I've got a folderbrowserdialog that will open to a certain folder, lets say C:\Temp.

Within this folder are a number of folders, e.g C:\Temp\1\ C:\Temp\2\ etc.

Now i only want the user to be able to select a folder inside C:\Temp, e.g select 1 or 2.

Is there an easy way to do this within the folderbrowserdialog or shall i rethink my approach and just display the folders in a dropbox or something and have them select if from there?

Cheers

Ben Bodie
  • 75
  • 12
  • Would it not make sense to just make your own dialog and display only the folders? – BugFinder Jun 22 '18 at 09:34
  • It probably would yes, if there's no easy way to do it with the folderbrowserdialog i'll do something like what you've said and just have a dialog with my folders listed, but wanted to see if there was an easy way first :) – Ben Bodie Jun 22 '18 at 09:36
  • Is there a "SelectionChanged" event in the dialog? If yes you could check the event and in case the selected path is outside the bounds drop the user back into the original. – Markus Deibel Jun 22 '18 at 10:33
  • In the default folderbrowser you can capture the 'ok' button being clicked, which is when a folder is selected. So you can do a loop at this stage. However i think i might just go with a combobox solution :-) – Ben Bodie Jun 22 '18 at 10:40

1 Answers1

0

If it's not a SpecialFolder you can't limit it to this folder only. If it is a special folder, then you can set a RootFolder property for FolderBrowserDialog.

var d= new System.Windows.Forms.FolderBrowserDialog { RootFolder= Environment.SpecialFolder.LocalApplicationData};
d.ShowDialog();
Rekshino
  • 6,954
  • 2
  • 19
  • 44