2
votes

I am using the SelectDirectory function in delphi in order to select a folder. I set the root to a default directory where the items a user is looking for should be. However if I want to be able navigate "above" where I am then I am unable to.

For example:

Lets say the default folder is C:\Program files\Default folder and when I am in there I can view all folders and select the one I want. However if I want to return to program file to look for another folder then I do not know how I do that.

Also I had considered using TOpenDialog but I found I wan unable to select a folder and see the files that are present in the folder (a setting which is important in SelectDirectory).

Is there a way to navigate above the root folder or possibly open the window cascaded down to the folder, as in it will display as though someone has navigated from computer to the root folder already?

Code:

SelectDirectory('Please select a directory', RootSearchLocation, ChosenDirectory,
               [sdShowEdit, sdNewUI, sdShowFiles, sdValidateDir], self);

Where RootSearchLocation is C:\Program files\Default folder and ChosenDirectory is the directory the user chooses.

Any more information needed let me know.

1
"...but I found I wan unable to select a folder and see the files that are present in the folder..." That's not true. You can see the files in it.Andreas Rejbrand
"is there a way to navigate above the root folder?" - No, that's how it works. - Set 'root' to an empty string, the dialog itself should navigate to 'directory' (ChosenDirectory).Sertac Akyuz
Also, I agree with @Sertac. Setting the root option is the same thing as telling the OS, "please only allow the user to select directories below this folder in the hierarchy".Andreas Rejbrand
@Sertac I have been leaving the chosendirectory blank as I assumed that was where the output was, I will try it with it having a directory before hand and let you know if it works, thanks =)Ridders
@SertacAkyuz That worked thanks. Not sure if I can accept a comment but that was what I was looking for =)Ridders

1 Answers

7
votes

It is not possible to navigate upwards from the specified 'root' folder in the browse for folder dialog. But you can specify an empty 'root', and fill in the 'directory' parameter with the directory you want the dialog to initially navigate.