//=====================================================================
// 函数名称: 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. scrollTop、offsetHeight和offsetTop等属性用法详解--转转转

    scrollTop.offsetHeight和offsetTop等属性用法详解: 标题中的几个相关相关属性在网页中有这大量的应用,尤其是在运动框架中,但是由于有些属性相互之间的概念比较混杂或者浏览器兼 ...

  2. 20181124_webAPI基础01_创建一个基础的WebAPI项目

    1. webApi属于RESTful架构风格, 而RESTful风格, 是以资源为视角来描述服务的 2. 创建webAPI项目 3. 选择webAPI, 然后mvc会自动引用 4. 点击确定, 就创建 ...

  3. Educational Codeforces Round 37-F.SUM and REPLACE题解

    一.题目 二.题目链接 http://codeforces.com/contest/920/problem/F 三.题意 给定$N$个范围在$[1, 1e6)$的数字和$M$个操作.操作有两种类型: ...

  4. HTML5按比例缩略图片并上传的实例

    <!DOCTYPE HTML PUBLIC> <html> <head> <meta charset="utf-8"> <sc ...

  5. solr统计只返回10或者100个数据的解决办法

    因为我所在的公司为政府做的项目[风险管理系统],其中涉及大量的统计展示,多数以整个市的区划,行业部门等方式返回,在昨天,我发现听过填报单位的方式返回时,始终只有100个数据.通过对比发现,在前辈的代码 ...

  6. java程序调优系列(一)intern()代替equal()

    1. 首先String不属于8种基本数据类型,String是一个对象. 因为对象的默认值是null,所以String的默认值也是null:但它又是一种特殊的对象,有其它对象没有的一些特性. 2. ne ...

  7. leetcode532

    public class Solution { public int FindPairs(int[] nums, int k) { var pair = new Dictionary<strin ...

  8. IBM X3650 M4 主板故障

    故障描述: 今天突然接到报警,一台服务器无法连通,无法登录.无法 ping 通. 打电话到 IDC ,授权工程师查看服务器状态,返回结果如下: 1.服务器关机状态 2.无法开机 ( 电源灯亮 ),按开 ...

  9. LinuxC编程怎么MakeFile

    在linux下我们都知道可以利用命令gcc hello.c -o hello 命令来变异c语言程序.其中gcc hello.c -o hello中 hello是给这个编译后生成的可执行文件取个别名 再 ...

  10. 14.Longest Common Prefix (String)

    Write a function to find the longest common prefix string amongst an array of strings. class Solutio ...