unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
IdFTP1: TIdFTP;
OpenDialog1: TOpenDialog;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button2: TButton;
Edit4: TEdit;
Label4: TLabel;
SpeedButton1: TSpeedButton;
Label6: TLabel;
Button3: TButton;
Label5: TLabel;
ProgressBar1: TProgressBar;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
procedure IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure IdFTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button3Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
ftp : TidFTP;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ftp.Username := Edit1.Text;
ftp.Password := Edit2.Text;
ftp.Host := Edit3.Text;
ftp.Port := 21;
sleep(100);
ftp.Connect;
ftp.Put(Edit4.Text, ExtractFileName(Edit4.Text));
ftp.Disconnect;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
OpenDialog1.Execute;
Edit4.Text := OpenDialog1.FileName;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ftp := TidFTp.Create(nil);
end;
procedure TForm1.IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
ProgressBar1.Position := AWorkCount;
Application.ProcessMessages;
end;
procedure TForm1.IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
ProgressBar1.Max := AWorkCountMax;
end;
procedure TForm1.IdFTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
ProgressBar1.Position := 0;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ftp.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Label6.Caption := '';
end;
end.