|
这是delphi获取path下 .jpg .bmp文件列表的函数,稍微修改一下,加一个目录层数控制,改一下扩展名就差不离了呀。你看看有否参考作用。
function GetFileList(Path,jpgFile,bmpfile:string):TStringList ;
var
sch:TSearchrec;
s:string;
begin
Result:=TStringlist.Create;
Path := trim(Path);
if COPY(Path,LENGTH(PATH),1) <> '\' then Path := trim(Path) + '\';
if not DirectoryExists(Path) then
begin
Result.Clear;
exit;
end;
if FindFirst(Path + '*', faAnyfile, sch) = 0 then
begin
repeat
if ((sch.Name = '.') or (sch.Name = '..')) then Continue;
if DirectoryExists(Path+sch.Name) then
Result.AddStrings(GetFileList(Path+sch.Name,jpgFile,bmpfile))
else
begin
s:= UpperCase(extractfileext(Path+sch.Name));
if ( S= '.JPG') or (S = '.BMP') or (jpgFile='.*') then
Result.Add(Path+sch.Name);
end;
until FindNext(sch) <> 0;
SysUtils.FindClose(sch);
end;
end; |
|