admin

[系统应用] 搜索文件夹目录下指定类型文件

//搜索文件夹下指定类型文件

function GetDirFileName(Dir,ExtName: string): TStringList;

var

  FSearchRec: TSearchRec;

  FileList: TStringList;

  FindResult: Integer;

begin

  if Dir[length(Dir)] <> '\' then

    Dir := Dir + '\';

  FileList := TStringList.Create;

  FindResult := FindFirst(Dir + '*.'+ExtName, faAnyFile, FSearchRec); //

  try

    while FindResult = 0 do

    begin

      if (FSearchRec.name <> '.') and (FSearchRec.name <> '..') then

        FileList.Add(LowerCase(Dir + FSearchRec.Name));

      FindResult := FindNext(FSearchRec);

    end;

  finally

    SysUtils.FindClose(FSearchRec);

    //FindClose(FSearchRec);

    dir := '';

  end;

  Result := FileList;

end; 



GetDirFileName(lbl2.Hint,'JPG');

#1楼
发帖时间:1月前   |   查看数:0   |   回复数:0
游客组