unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP;
type
TForm1 =
class(TForm)
ListBox1: TListBox;
Button1: TButton;
CheckBox1: TCheckBox;
Button2: TButton;
IdFTP1: TIdFTP;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure GetFilesInDirectory(ADirectory:
string; AMask:
String; AList: TStrings; ARekursiv: Boolean);
var
SR: TSearchRec;
begin
if (ADirectory<>'
')
and (ADirectory[length(ADirectory)]<>'
\')
then
ADirectory:=ADirectory+'
\';
if (FindFirst(ADirectory+AMask,faAnyFile-faDirectory,SR)=0)
then begin
repeat
if (SR.
Name<>'
.')
and (SR.
Name<>'
..')
and (SR.Attr<>faDirectory)
then
AList.Add(ADirectory+SR.
Name)
until FindNext(SR)<>0;
FindClose(SR);
end;
if ARekursiv
then
if (FindFirst(ADirectory+'
*.*',faDirectory,SR)=0)
then
begin
repeat
if (SR.
Name<>'
.')
and (SR.
Name<>'
..')
then
GetFilesInDirectory(ADirectory+SR.
Name,AMask,AList,True);
until FindNext(SR)<>0;
FindClose(SR);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.Clear;
GetFilesInDirectory('
C:\','
*.*',Listbox1.Items,checkbox1.Checked);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
listbox1.Items.SaveToFile('
c:\indhold.txt');
end;
end.