From RAD Studio API Documentation
Jump to: navigation, search


function SelectDirectory(var Directory: string; Options: TSelectDirOpts; HelpCtx: Longint): Boolean;
function SelectDirectory(const Caption: string; const Root: WideString; var Directory: string; Options: TSelectDirExtOpts; Parent: TWinControl): Boolean;
function SelectDirectory(const StartDirectory: string; out Directories: TArray<string>; Options: TSelectDirFileDlgOpts = []; const Title: string = ''; const FolderNameLabel: string = ''; const OkButtonLabel: string = ''): Boolean;


extern DELPHI_PACKAGE bool __fastcall SelectDirectory(System::UnicodeString &Directory, TSelectDirOpts Options, int HelpCtx)/* overload */;


Type Visibility Source Unit Parent
function public
Vcl.FileCtrl Vcl.FileCtrl


Brings up a Select Directory dialog to allow the user to either enter or select a directory.

The value passed in the Directory parameter appears as the currently selected directory when the dialog box appears. SelectDirectory returns the new selection in Directory. The Options parameter specifies the custom response of the Select Directory dialog. Check the possible values that Options can take depending on each syntax.

  • Use the first syntax with Options as a set of TSelectDirOpt. The HelpCtx parameter is the help context ID number.
  • Use the second syntax with Options as a set of TSelectDirExtOpt. The Caption parameter specifies a caption for the Select Directory dialog. The Root parameter specifies the root directory from which to browse. If Options is the empty set, the user can only select a directory that already exists. No edit box is provided for the user to enter a new directory name. If Options is not empty, the included values determine how the dialog responds when the user types a nonexistent directory name.
  • Use the third syntax with Options as a set of TSelectDirFileDlgOpt. With this syntax, SelectDirectory displays a Select Directory dialog that uses the Microsoft IFileDialog interface to provide the same options as common dialogs in Microsoft Windows Vista or later Windows operating systems. The rest of the parameters are the following:
    • StartDirectory: specifies the currently selected directory when the Select Directory dialog appears.
    • Directories: SelectDirectory returns the new selected directory in this parameter. In case that you enable multiple selection in TSelectDirFileDlgOpts, then Directories receives the entire set of selected directories as different elements in the array.
    • Title, FolderNameLabel and OkButtonLabel: allow you to customize the text that SelectDirectory shows in the dialog box.

With either syntax, SelectDirectory returns True if you select a directory and click OK, and False if you click Cancel or close the dialog box without selecting a directory.

See Also

Code Examples