Delphi2010新功能:TDirectory.GetFiles 支持通配符


本文整理自网络,侵删。

 
Delphi 2010 新增功能之: IOUtils 单元: TDirectory.GetFiles 支持通配符

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses IOUtils, Types;

const path = 'C:\Program Files\Embarcadero\RAD Studio\7.0';

//获取指定目录下有 Li 开头的文件
procedure TForm1.Button1Click(Sender: TObject);
var
  files: TStringDynArray;
  str: string;
begin
  files := TDirectory.GetFiles(path, 'Li*.*');
  Memo1.Clear;
  for str in files do Memo1.Lines.Add(str);
end;

//获取指定目录及其子目录下文件名只有 3 个字母的 pas 文件
procedure TForm1.Button2Click(Sender: TObject);
var
  files: TStringDynArray;
  str: string;
begin
  files := TDirectory.GetFiles(path, '???.pas', TSearchOption.soAllDirectories);
  Memo1.Clear;
  for str in files do Memo1.Lines.Add(str);
end;

end.


来源:http://blog.sina.com.cn/s/blog_3cb6a78c0100ityn.html

相关阅读 >>

Delphi unigui hyperserver

Delphi not 与整数

dephi获取系统常量

pos、ansipos、fillchar在Delphi2010中unicode的问题

Delphi写qq消息群发(模拟按键精灵)

Delphi 写开关防火墙代码

Delphi程序与chm帮助关联的简单实现

Delphi删除文件

Delphi 判断窗体是否创建 存在

Delphi idftp

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...