用 IOUtils 单元下的 TDirectory.GetFiles 获取文件列表太方便了; DEMO下载IOUnit1 下面的例子只是 TDirectory.GetFiles 的典型应用… unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) btn1: TButton; btn2: TButton; btn3: TButton; mmo1: TMemo; lbl1: TLabel; procedure btn1Click(Sender: TObject); procedure btn2Click(Sender: TObject); procedure btn3Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses IOUtils, Types; const path = 'D:/Program Files/Embarcadero/RAD Studio/7.0'; procedure TForm1.btn1Click(Sender: TObject); var dir: TDirectory; {这是个结构, 后面就不再声明了, 将直接使用} files: TStringDynArray; {TStringDynArray = array of string;} str: string; begin files := dir.GetFiles(path); mmo1.Clear; for str in files do mmo1.Lines.Add(str); end; procedure TForm1.btn2Click(Sender: TObject); var files: TStringDynArray; str: string; begin files := TDirectory.GetFiles(path, '*.txt'); mmo1.Clear; for str in files do mmo1.Lines.Add(str); end; procedure TForm1.btn3Click(Sender: TObject); var files: TStringDynArray; str: string; begin files := TDirectory.GetFiles(path, '*.txt', TSearchOption.soAllDirectories); mmo1.Clear; for str in files do mmo1.Lines.Add(str); end; end.