在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Delphi遍历文件夹及子文件夹{------------------------------------------------------------------------------- Eg:ListBox1.Items:= MakeFileList( 'E:\极品飞车','.exe') ; function MakeFileList(Path,FileExt:string):TStringList ; var sch:TSearchrec; begin Result:=TStringlist.Create; if rightStr(trim(Path), 1) <> '\' then Path := trim(Path) + '\' else Path := trim(Path); if not DirectoryExists(Path) then begin Result.Clear; exit; end; if FindFirst(Path + '*', faAnyfile, sch) = 0 then begin repeat Application.ProcessMessages; if ((sch.Name = '.') or (sch.Name = '..')) then Continue; if DirectoryExists(Path+sch.Name) then begin Result.AddStrings(MakeFileList(Path+sch.Name,FileExt)); end else begin if (UpperCase(extractfileext(Path+sch.Name)) = UpperCase(FileExt)) or (FileExt='.*') then Result.Add(Path+sch.Name); end; until FindNext(sch) <> 0; SysUtils.FindClose(sch); end; end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论