Daftar Semua File Dalam Direktory


Tips & Trik Delphi, Tips Belajar Delphi, Belajar Delphi Online
unit Unit1;

interface

uses

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

type
TForm1 = class(TForm)
btn1: TButton;
lst1: TListBox;
procedure btn1Click(Sender: TObject);
private

{ Private declarations }
public
{ Public declarations }
end;

var

Form1: TForm1;

implementation


{$R *.DFM}

procedure ListFileDir(Path: string; FileList: TStrings);
var
SR: TSearchRec;
begin
if FindFirst(Path + ‘*.*’, faAnyFile, SR) = 0 then
begin
repeat
if (SR.Attr <> faDirectory) then
begin
FileList.Add(SR.Name);
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
end;

procedure TForm1.btn1Click(Sender: TObject);
begin
ListFileDir(‘C:\WINDOWS\’, Lst1.Items);
end;

end.

TransCODE Software