zoukankan      html  css  js  c++  java
  • 遍历文件夹及子文件夹

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

       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;

  • 相关阅读:
    一些常用的库
    isKindOfClass isMemeberOfClass 的区分
    自学知识的博客
    更新进度
    ORA-01950:对表空间“”XXXX”无权限,解决办法
    ORA-01589错误的解决办法
    背景四
    专题-主存储器与Cache的地址映射方式
    C语言中宏的相关知识
    Lab1:Linux内核编译及添加系统调用(详细版)
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940791.html
Copyright © 2011-2022 走看看