zoukankan      html  css  js  c++  java
  • Delphi下遍历文件夹下所有文件的递归算法

    Delphi下遍历文件夹下所有文件的递归算法
    https://www.cnblogs.com/china1/p/3395146.html

    {-------------------------------------------------------------------------------
    过程名: MakeFileList 遍历文件夹及子文件夹
    参数: Path,FileExt:string 1.需要遍历的目录 2.要遍历的文件扩展名
    返回值: TStringList

    USE StrUtils

    Eg:ListBox1.Items:= MakeFileList( 'E:极品飞车','.exe') ;
    ListBox1.Items:= MakeFileList( 'E:极品飞车','.*') ;
    -------------------------------------------------------------------------------}

    function MakeFileList(Path,FileExt:string):TStringList ;
    var
    sch:TSearchrec;
    begin
    Result:=TStringlist.Create;
     
    if rightStr(trim(Path), 1) <> '' then
        Path := trim(Path) + ''
    else
        Path := trim(Path);
     
    if not DirectoryExists(Path) then
    begin
        Result.Clear;
        exit;
    end;
     
    if FindFirst(Path + '*', faAnyfile, sch) = 0 then
    begin
        repeat
           Application.ProcessMessages;
           if ((sch.Name = '.') or (sch.Name = '..')) then Continue;
           if DirectoryExists(Path+sch.Name) then
           begin
             Result.AddStrings(MakeFileList(Path+sch.Name,FileExt));
           end
           else
           begin
             if (UpperCase(extractfileext(Path+sch.Name)) = UpperCase(FileExt)) or (FileExt='.*') then
             Result.Add(Path+sch.Name);
           end;
        until FindNext(sch) <> 0;
        SysUtils.FindClose(sch);
    end;
    end;
  • 相关阅读:
    dnn
    DATAGRID学习
    在.net下的换行符
    treeview
    《25项最优时间管理工具与技巧》
    vim常用操作
    【Google给毕业生的忠告】
    MySQL的安装、使用及权限管理
    各种国际化标准组织
    ubuntu thunderbird 邮箱 163 配置 不能发送问题
  • 原文地址:https://www.cnblogs.com/fhweixin/p/13743246.html
Copyright © 2011-2022 走看看