[Delphi] 纯文本查看 复制代码 unit Unit4;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, StdCtrls;
type
TForm4 = class(TForm)
Edit1: TEdit;
Memo1: TMemo;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function FindAllFileInADirectory(Directory: string; RetList: TStringList): TStringList;
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
var
TempList: TStringList;
begin
TempList := TStringList.Create;
TempList := FindAllFileInADirectory(Edit1.text, TempList);
memo1.Lines.Clear;
memo1.Lines.Assign(TempList);
TempList.clear;
end;
function TForm4.FindAllFileInADirectory(Directory: string; RetList: TStringList): TStringList;
var
SearchRec: TSearchRec;
begin
if FindFirst(Directory + '\*.pas', $0000003F, SearchRec) = 0 then
begin
repeat
RetList.Add(Directory + '\' + SearchRec.Name);
until (FindNext(SearchRec) <> 0);
end;
FindClose(SearchRec);
end;
end.
|