zoukankan      html  css  js  c++  java
  • 取指定文件夾及其子文件夾內指定類型文件列表

    //取指定文件夾及其子文件夾內指定類型文件列表

    procedure _GetFileList(AStrings: TStrings; ASourFile, FileName: string);
    // 調用示例: _GetFileList(FileList, 'c:/', '*.pas')
    var
      sour_path, sour_file: string;
      TmpList: TStringList;
      FileRec, subFileRec: TSearchrec;
      i: Integer;
    begin
      if rightStr(trim(ASourFile), 1) <> '/' then
        sour_path := trim(ASourFile) + '/'
      else
        sour_path := trim(ASourFile);
      sour_file := FileName;

      if not DirectoryExists(sour_path) then
      begin
        AStrings.Clear;
        exit;
      end;

      TmpList := TStringList.Create;
      TmpList.Clear;

      if FindFirst(sour_path + FileName, faAnyfile, FileRec) = 0 then
      repeat
        if ((FileRec.Attr and faDirectory) = 0) then
          AStrings.Add(sour_path+FileRec.Name);
      until FindNext(FileRec) <> 0;
      if FindFirst(sour_path + '*.*', faAnyfile, FileRec) = 0 then
      repeat
        if ((FileRec.Attr and faDirectory) <> 0) then
        begin
          if ((FileRec.Name<> '.') and (FileRec.Name  <> '..')) then
            _GetFileList(AStrings, sour_path+ FileRec.Name + '/',  sour_file);
        end;
      until FindNext(FileRec) <> 0;
      FindClose(FileRec);
    end;

  • 相关阅读:
    POJ1006 UVA756 UVALive5421 Biorhythms【中国剩余定理】
    HDU2098 分拆素数和
    HDU2098 分拆素数和
    HDU2099 整除的尾数【模除】
    HDU2099 整除的尾数【模除】
    I00003 贝尔三角形
    I00003 贝尔三角形
    模乘逆元与孙子定理
    Maximal Binary Matrix CodeForces
    带精度问题的二分的方法
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940763.html
Copyright © 2011-2022 走看看