Delphi浏览文件夹

Delphi如何实现浏览文件夹,并得出所选择的文件夹名:
SelectDirectory函数(FileCtrl单元)
1、function SelectDirectory(const Caption: string; const Root: WideString; out Directory: string): Boolean; overload;
2、function SelectDirectory(var Directory: string; Options: TSelectDirOpts; HelpCtx: Longint): Boolean; overload;
注意:使用前请uses FileCtrl;
第1种调用格式示例为:
const
  sCaption = '文件夹';       //弹出框标题名(非弹出框窗体名)
  sRoot = '';                    //初始文件夹(如'C:/','D:/DownLoad'等, 不存在则从桌面)
var
  sDir: string;
begin
  if SelectDirectory(sCaption, sRoot, sDir) then
  //已返回所选文件夹路径给sDir,自行处理
end;
结果下图:
 
第2种调用格式示例为:
const
  SELDIRHELP = 1000;
var
  sDir: string;            //初始文件夹(如'C:/','D:/DownLoad'等)
begin
  sDir := '';
  if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt], SELDIRHELP) then
    //已返回所选文件夹路径给sDir,自行处理
end;
结果下图:
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值