//获取一个文件夹下的所有文件
//不包括文件夹里面的文件

//ListBox1.Items:= searchfile('Z:\');
//注意,path后面要有'\';
function  Searchfile(path:string):TStringList;

var
   SearchRec:TSearchRec;
   found:integer;
begin
   Result:=TStringList.Create; 
   found:=FindFirst(path+'*.*',faAnyFile,SearchRec);
   while found=0 do
     begin

         if (SearchRec.Name<>'.') and(SearchRec.Name<>'..') and (SearchRec.Attr<>faDirectory) then

             Result.Add(SearchRec.Name);

         found:=FindNext(SearchRec);

     end;

   FindClose(SearchRec);

end;

//搜索1个文件下面的文件
// GetDirFiles (ListView1,'Z:\aa\2013-06-23\');

procedure GetDirFiles(ListView:TListView;path: string;fileter:string='*.*');

var
  SearchRec: TSearchRec;
  found: integer;
begin
  ListView.Items.Clear;

  found := FindFirst(path + fileter, faAnyFile, SearchRec);

  while found = 0 do

  begin

    if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') and (SearchRec.Attr <> faDirectory) then

        ListView.Items.Add.Caption:=SearchRec.Name;
    found := FindNext(SearchRec);
  end;

  FindClose(SearchRec);
end;

上面一个只获取当前目录下所有文件,如果要获取该目录下的子目录的文件,看下面

 

Delphi获取目录下所有文件名的更多相关文章

  1. python 遍历, 获取目录下所有文件名和文件夹的方法-----os.walk(), os.listdir

    http://www.runoob.com/python/os-walk.html https://www.cnblogs.com/dreamer-fish/p/3820625.html 转载于:ht ...

  2. python获取指定目录下所有文件名os.walk和os.listdir

    python获取指定目录下所有文件名os.walk和os.listdir 觉得有用的话,欢迎一起讨论相互学习~Follow Me os.walk 返回指定路径下所有文件和子文件夹中所有文件列表 其中文 ...

  3. Python获取路径下所有文件名

    python 获取当前文件夹下所有文件名   os 模块下有两个函数: os.walk() os.listdir() 1 # -*- coding: utf-8 -*- 2 3 import os 4 ...

  4. C# 获取目录下文件

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  5. Java 读取指定目录下的文件名和目录名

    需求:读取指定目录下的文件名和目录名 实现如下: package com.test.common.util; import java.io.File; public class ReadFile { ...

  6. 取CPU序列号,获取网卡,取硬盘系列号,获取目录下的文件,强制删除目录

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  7. python生成器 获取 目录下文件

    # os.walk()和os.list 都是得到所有文件的列表, 如果目录下文件特别多, 上亿了, 我们就需要生成器的方式获取 # 要求目录下面没有目录, 会递归到子目录下面找文件, (如果有子目录可 ...

  8. Python开发【笔记】:获取目录下所有文件

    获取文件 import os def sub_dirs(rdir): li = os.listdir(rdir) return li def main(rdir): content = sub_dir ...

  9. Python--通过索引excel表将文件进行文件夹分类的脚本+读取指定目录下所有文件名的脚本

    1.通过索引excel表将文件进行文件夹分类的脚本,此脚本由于将ip和id对应并生成对应id的文件夹将文件进行分类,也可以任意规定表格内容,通过vul_sc_ip.txt和xlsx文件进行索引. # ...

随机推荐

  1. hdu 1166(树状数组 或 线段树)

    线段树 (本题无需建树,少了很多) #include<cstdio> #include<cstring> int sum[5000005],rt,data,lb,rb,n,m; ...

  2. 宏ut_2pow_remainder

    求余数 12%8=4 n%m也能计算出余数,但效率可能比位操作要低一些 /*************************************************************// ...

  3. innodb 间隙锁

    innodb 间隙锁, 参考 MySQLInnoDB锁机制(二) 针对于辅助索引,也称范围索引 间隙锁只会出现在辅助索引上,唯一索引和主键索引是没有间隙锁.间隙锁(无论是S还是X)只会阻塞insert ...

  4. vbox android x86 分辨率

    D:\Program Files\Oracle\VirtualBox>VBoxManage setextradata "android" "CustomVideoM ...

  5. [原]Unity3D深入浅出 - 认识开发环境中的自带的Package资源包

    Character Controller:角色控制器 Glass Refraction(pro only):玻璃反射资源包 Image Effects :图像效果资源包 Light Cookies:光 ...

  6. HAOI2006受欢迎的牛

    求出强联通分量之后判断出度为0的点有几个,有1个就输出这个分量的点的数目,否则输出0: var i,j,n,m,x,y,ans1,ans2,t,cnt,top:longint; head,next,g ...

  7. jqGrid如何实现单选。

    设置如下:multiselect:true // multi-select checkboxes appear multiboxonly:true // checkboxes act like rad ...

  8. OK335xS LAN8710 phy driver hacking

    /******************************************************************** * OK335xS LAN8710 phy driver h ...

  9. webapp开发经验和资料

    开发经验: 开发资料: 1. http://xuui.net/librarys/webapps/webapp-development-of-commonly-used-code-snippets.ht ...

  10. Java [leetcode 22]Generate Parentheses

    题目描述: Given n pairs of parentheses, write a function to generate all combinations of well-formed par ...