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;

  • 相关阅读:
    Async、Await
    CommandLineParser命令行解析类
    Dispose in c#
    授权oAuth
    Hadoop技术内幕1——源代码环境准备
    postgreSql——时区问题
    Linux命令3——c
    Linux命令2——b
    Linux命令1——a
    hadoop的Linux操作
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940763.html
Copyright © 2011-2022 走看看