Selecting a directory with TOpenDialog

后端 未结 5 1033
长情又很酷
长情又很酷 2020-12-04 17:40

I\'d really like to know the various ways I could select a directory with the TOpenDialog, whether it be downloading a new component or using what is provided by Delphi, but

5条回答
  •  春和景丽
    2020-12-04 18:14

    Just include

    FileCtrl.pas
    
    var
      sDir:String;
    begin
      SelectDirectory('Your caption','',sDir);
    end;
    

    Just leave second argument empty if want to see all directories including desktop. If you set second argument to any valid Path, then your dialog will have that path to top folder and you can not navigate beyond that.

    For example:

    SelectDirectory('Your caption','C:\',sDir) will not let you select anything beyond C:\, like D:\ or E:\ etc.

    So it is good to leave it empty.

提交回复
热议问题