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 android权限

Delphi 读取图像文件base64编码加载到image组件显示图片

Delphi中简单的调用单元unit实例

Delphi 构建时间 -encodedatetime … tryencodedatetime

Delphi 增加/获得windows用户帐号

Delphi 获取毫秒级时间戳

Delphi编程实现sql server挂起清除

Delphi unigui 安装和配置hyperserver

Delphi内嵌汇编实现�载任意进程的某个dll

Delphi twebbrowser 响应回车键(ewb响应正常,无需额外代码)

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



打赏

取消

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

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

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

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

评论

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