Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DELPHI - How to use opendialog1 for choosing a folder? [duplicate]

Possible Duplicate:
Delphi: Selecting a directory with TOpenDialog

I need to open a specific folder on my project. When I use opendialog1, I can only open a file. How about opening a folder ?

wanted - open folder dialog in Delphi

PS : I use Delphi 2010

like image 811
Galvion Avatar asked Nov 28 '22 04:11

Galvion


1 Answers

On Vista and up you can show a more modern looking dialog using TFileOpenDialog.

var
  OpenDialog: TFileOpenDialog;
  SelectedFolder: string;
.....
OpenDialog := TFileOpenDialog.Create(MainForm);
try
  OpenDialog.Options := OpenDialog.Options + [fdoPickFolders];
  if not OpenDialog.Execute then
    Abort;
  SelectedFolder := OpenDialog.FileName;
finally
  OpenDialog.Free;
end;

which looks like this:

enter image description here

like image 113
David Heffernan Avatar answered Dec 04 '22 10:12

David Heffernan