//=====================================================================
// 函数名称: FindPathFiles
// 功能描述: 找指定目录下的文件
// 参    数:  APath   : 路径名称
//            APropty : 属性名称(*.* | *.txt)
//            AFiles  : 文件列表
//            IsAddPath: 是否增加路径
// 作者:    
// 时间:    
// 返 回 值:
// 说    明:
//=====================================================================
procedure FindPathFiles(const APath: string; AFiles: TStrings;
  const APropty: String = '*.*'; IsAddPath: Boolean = False);
var
  FS: TSearchRec;
  FPath: String;
  AddPath: string;
begin
  FPath := IncludeTrailingPathDelimiter(APath);
  AddPath := IfThen(IsAddPath, FPath, '');
  if FindFirst(FPath + APropty, faAnyFile, FS) = 0 then
  begin
    repeat
    if //(FS.Name <> '.') and (FS.Name <> '..') and
       ((FS.Attr and faDirectory) <> faDirectory) then
       AFiles.Add(AddPath + FS.Name);
    until FindNext(FS) <> 0;
    SysUtils.FindClose(FS);
  end;
end;

//=====================================================================
// 函数名称: FindAllFiles
// 功能描述: 找指定目录下的所有文件
// 参    数:  APath    : 路径名称
//            APropty  : 属性名称(*.* | *.txt)
//            AFiles   : 文件列表
//            IsAddPath: 是否增加路径
// 作者:    
// 时间:    
// 返 回 值:
// 说    明:
//=====================================================================
procedure FindAllFiles(const APath: string; AFiles: TStrings;
  const APropty: String = '*.*'; IsAddPath: Boolean = False);
var
  FS: TSearchRec;
  FPath: String;
  AddPath: string;
begin
  FPath := IncludeTrailingPathDelimiter(APath);
  AddPath := IfThen(IsAddPath, FPath, '');
  if FindFirst(FPath + APropty, faAnyFile, FS) = 0 then
  begin
    repeat
    if (FS.Name <> '.') and (FS.Name <> '..') then
      if ((FS.Attr and faDirectory) = faDirectory) then
        FindAllFiles(FPath + FS.Name, AFiles, APropty, IsAddPath)
      else
        AFiles.Add(AddPath + FS.Name);
    until FindNext(FS) <> 0;
    SysUtils.FindClose(FS);
  end;
end;

DELPHI如何获取某目录下的所有文件名?的更多相关文章

  1. 获取bundle目录下的所有图片文件名

    今天在写代码时候,偶然发现自己忘记了一些oc的基础知识(这里指的是获取bundle目录下的所有图片),感到很不爽.在百度了几次,发现自己的领悟能力实在不行,感觉萌萌的::>_<:: 好了, ...

  2. C#获取一个目录下的所有文件名

    今天在做图像训练的时候发现需要把一大堆图片进行处理再读进分类器,本来是用C++写的,结果发现并不会,于是就用回了我最爱的C#,结果棒棒哒. 代码如下,简单粗暴,比网上C++的语法好看多了 using ...

  3. lua 获取指定目录下指定后缀文件名

    lfs库是很好的选择,可惜不会编译,无奈只能自己写个简单的lua库.代码如下: #include <io.h> #include <stdio.h> #include &quo ...

  4. 一个获取指定目录下一定格式的文件名称和文件修改时间并保存为文件的python脚本

    摘自:http://blog.csdn.net/forandever/article/details/5711319 一个获取指定目录下一定格式的文件名称和文件修改时间并保存为文件的python脚本 ...

  5. PHP 获取指定目录下所有文件(包含子目录)

    PHP 获取指定目录下所有文件(包含子目录) //glob — 寻找与模式匹配的文件路径 $filter_dir = array('CVS', 'templates_c', 'log', 'img', ...

  6. 安卓获取Assets目录下的资源

    获取Assets目录下的资源 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 ! ...

  7. TDirectory.GetFileSystemEntries获取指定目录下的目录和文件

    使用函数: System.IOUtils.TDirectory.GetFileSystemEntries 所有重载: class function GetFileSystemEntries(const ...

  8. TDirectory.GetFiles获取指定目录下的文件

    使用函数: System.IOUtils.TDirectory.GetFiles 所有重载: class function GetFiles(const Path: string): TStringD ...

  9. c# 获取指定目录下的所有文件并显示在网页上

    参考文献: FileInfo 的使用  https://msdn.microsoft.com/zh-cn/library/system.io.fileinfo_methods(v=vs.110).as ...

随机推荐

  1. C语言的第二次实验报告

    一.思路及方法 11-8 螺旋方阵 设计二维数组,通过对方阵的行和列进行特征分析找出其中规律,利用循环即可将方阵输出. 12-6 字符串转换成十进制整数 设计字符数组,用getchar函数逐个截取,并 ...

  2. 2018-2019-1 20165226《信息安全系统设计基础》 pwd命令的实现

    2018-2019-1 20165226<信息安全系统设计基础> pwd命令的实现 一.学习pwd 查看pwd 得知一个嫩过去文件路径的函数--getcwd i节点值 通过ls -i -a ...

  3. 汇编_指令_JMP

    JMP指令 JMP是汇编语言中的无条件跳转指令.无条件跳转指令可转到内存中任何程序段.转移地址可在指令中给出,也可以在寄存器中给出,或在储存器中指出. 中文名:无条件跳转指令 外文名:JMP 和调用指 ...

  4. C# 使用printDocument1.Print打印时不显示 正在打印对话框(里面还有一个讨厌的取消按钮)

    C#使用printDocument1.Print打印时不显示正在打印对话框有两种方法 第一种,使用PrintController PrintController printController = n ...

  5. Spring Boot 16 条最佳实践

    Spring Boot是最流行的用于开发微服务的Java框架.在本文中,我将与你分享自2016年以来我在专业开发中使用Spring Boot所采用的最佳实践.这些内容是基于我的个人经验和一些熟知的Sp ...

  6. ubuntu上安装 MySQL 启动/停止 连接MySQL

    1.Ubuntu上安装MySQL服务   1.安装服务端   sudo apt-get install mysql-server    2.安装客户端   sudo apt-get install m ...

  7. 使用D3D渲染YUV视频数据<转>

    源代码下载 转载地址:http://blog.csdn.net/dengzikun/article/details/5824874 源码地址:http://download.csdn.net/down ...

  8. 【转】C# 调用 C++ 数据转换

    原文:https://www.cnblogs.com/82767136/articles/2517457.html 在合作开发时,C#时常需要调用C++DLL,当传递参数时时常遇到问题,尤其是传递和返 ...

  9. Word编写代码时输出半角引号

    工具--自动更正选项--键入时自动套用格式,去掉直引号替换为弯引号.

  10. 数组/指针/const/字符串常量的使用传值问题

    #include<stdio.h> #include<string.h> int main() { ] = "abcd"; //常指针a指向字符串常量&qu ...