| There are FileOpenDialog and FileSaveDialog components on Delphi VCL. Sometimes you may need directory selection dialog, but no components are found on VCL. Do you know Delphi provides the solution as SelectDirectory().
Here are two examples for directory selection.
Following shows directory structure under d:delphi procedure TForm1.Button1Click(Sender: TObject);
var
DirSelected: string;
begin
if SelectDirectory('Select a folder:', 'D:Delphi', DirSelected) then
ShowMessage('You selected ' + DirSelected)
else
ShowMessage('You did not select a folder');
end;
Following shows driver names and files as well as directory structure.
procedure TForm1.Button2Click(Sender: TObject);
var
Dir: string;
begin
Dir := 'D:Delphi';
if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt], 0) then
ShowMessage('You selected ' + Dir)
else
ShowMessage('You did not select a folder');
end;
|