首 页 | 精品电影 | 音乐天堂 | 在线游戏 | Flash MTV | 三湘书屋 | 幽默笑话 | 三湘图库 | 美女写真 | IT知识库 | QQ贴图 | 加入书签

网页制作网络编程图形图象操作系统冲浪宝典软件教学网络安全认证考试通信技术电子商务业内动态书籍教程原码

最近更新 文章分类 多媒体类 精品软件

本站搜索:
您的位置:三湘时空 -> IT知识库 -> 文章分类 -> Delphi -> 查找某目录下的所有文件
查找某目录下的所有文件


文章类别:Delphi 来源: 作者: 发表日期:2006-2-4 字体:[ ]

小游戏 | 在线影院 | 幽默笑话 | 源码下载 | Flash MTV | 音乐试听 | 书屋 | 美女写真

(1)查找指定扩展名的文件
procedure TForm1.Button1Click(Sender: TObject);
var
  sr: TSearchRec;
begin
  ListBox1.Items.Clear ;
  if FindFirst('D:\work\*.*', faAnyFile, sr) = 0 then
  begin
    repeat
      if pos('.xls',lowercase(sr.Name))>0 then
        ListBox1.Items.Add(sr.Name)  ;
    until FindNext(sr) <> 0;
    FindClose(sr);
  end;
end;

(2)查找某目录下的所有文件,非目录
procedure TForm1.Button2Click(Sender: TObject);
var
  sr: TSearchRec;
begin
  ListBox1.Items.Clear ;
  if FindFirst('D:\work\*.*', faAnyFile, sr) = 0 then
  begin
    repeat
      if (sr.Attr and faDirectory)=0 then
        ListBox1.Items.Add(sr.Name+ '   '+intToStr(sr.Attr))  ;
    until FindNext(sr) <> 0;
    FindClose(sr);
  end;
  showMessage(intToStr(ListBox1.Items.count));
end;

(3)查找某目录下的所有目录,包含 “.”  “..”
procedure TForm1.Button2Click(Sender: TObject);
var
  sr: TSearchRec;
begin
  ListBox1.Items.Clear ;
  if FindFirst('D:\work\*.*', faAnyFile, sr) = 0 then
  begin
    repeat
      if (sr.Attr and faDirectory)<>0 then
        ListBox1.Items.Add(sr.Name+ '   '+intToStr(sr.Attr))  ;
    until FindNext(sr) <> 0;
    FindClose(sr);
  end;
  showMessage(intToStr(ListBox1.Items.count));
end;

上一篇:SaveComponentByFile 下一篇:根据时间日期格式从字符串中解析日期时间
本栏目热门文章
·Delphi工具—反编译Delphi(三) 2006-2-4
·Delphi工具—反编译Delphi(二) 2006-2-4
·Delphi工具——反编译Delphi(一) 2006-2-4
·用FASTREPORT实现WEB应用中自定义报表 2006-2-4
·Delphi中ScriptControl的高级应用(一) 2006-2-4
·利用内存映射文件扩充程序可用的内存 2006-2-4
·QQ聊天记录器演示程序 2006-2-4
·Delphi与DirectShow&amp;DSPack/在 2006-2-4
·UltraEdit也支持Delphi语法高亮 2006-2-4
·DirectShow之接口实战篇(二) 2006-2-4
新近更新文章
·BPCS系统现金流量分析工具开发日志 2006-2-4
·程序间相互通讯问题的解决 2006-2-4
·如何获取本地HTML文件的标题,超级链接 2006-2-4
·建立自己的csdn知识管理库(1) 2006-2-4
·使用Delphi开发多媒体播放音轨问题的FAQ(原创) 2006-2-4
·监视资源管理器的文件变化 2006-2-4
·实现在virtualStringtree中编辑的标准步骤 2006-2-4
·WINDOWS编程技巧之DELPHI篇 2006-2-4
·DELPHI面向对象支持特点--保护级类成员的应用 2006-2-4
·取Run下所有值(原创) 2006-2-4
首 页 | 软件发布 | 广告联系 | 下载帮助 | 意见反馈 | 网站地图
  CopyRight? 2002-2004 WWW.SXSKY.NET? All Rights Reserved
三湘时空 站长QQ:82675303 Email: