Delphi – 如何获取目录的所有文件的列表
发布时间:2020-12-15 03:52:12 所属栏目:大数据 来源:网络整理
导读:我正在使用delphi,当我执行openpicturedialog时,我想要一个目录的所有文件的列表. i.e.,When open dialog is executed and i select one file from it,I want the list of all files from the directory of selected file. 您甚至可以建议我从TOpenDialog的F
我正在使用delphi,当我执行openpicturedialog时,我想要一个目录的所有文件的列表.
您甚至可以建议我从TOpenDialog的FileName属性获取目录名称 解决方法
@Himadri,OpenPictureDialog的主要目标不是选择一个目录,反正如果你使用这个对话框的另一个目的,你可以试试这个代码.
Var Path : String; SR : TSearchRec; DirList : TStrings; begin if OpenPictureDialog1.Execute then begin Path:=ExtractFileDir(OpenPictureDialog1.FileName); //Get the path of the selected file DirList:=TStringList.Create; try if FindFirst(Path + '*.*',faArchive,SR) = 0 then begin repeat DirList.Add(SR.Name); //Fill the list until FindNext(SR) <> 0; FindClose(SR); end; //do your stuff finally DirList.Free; end; end; end; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |