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;

  • 相关阅读:
    MySQL快速入门
    关系模型
    从Qt到PyQt
    Qt 绘图与动画系统
    Django请求响应对象
    Django控制器
    Django模板
    第一个Django项目
    图的存储与遍历
    AOE网与AOV网
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940763.html
Copyright © 2011-2022 走看看