unit pubunit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Mask, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdFTP, IniFiles, ComCtrls, IdAntiFreezeBase, IdAntiFreeze;
type
TForm1 =
class(TForm)
IP: TEdit;
Label1: TLabel;
Label2: TLabel;
PathEdit: TEdit;
Label3: TLabel;
UserID: TEdit;
Label4: TLabel;
PasswordEdit: TEdit;
Label5: TLabel;
Button1: TButton;
IdFTP1: TIdFTP;
Memo1: TMemo;
Edit1: TEdit;
ProgressBar1: TProgressBar;
StatusBar1: TStatusBar;
IdAntiFreeze1: TIdAntiFreeze;
procedure Button1Click(Sender: TObject);
procedure IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
private
{ Private declarations }
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
IdFTP1.Username := UserID.Text;
IdFTP1.Password := PasswordEdit.Text;
IdFTP1.Host :=
IP.Text;
IdFTP1.Connect;
IdFTP1.ChangeDir(PathEdit.Text);
IdFTP1.Put(Edit1.Text,
ExtractFileName(Edit1.Text));
end;
procedure TForm1.IdFTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
ProgressBar1.Max := AWorkCountMax;
ProgressBar1.Position := 0;
end;
procedure TForm1.IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
Var
S:
String;
TotalTime: TDateTime;
H, M, Sec, MS: Word;
DLTime: Double;
STime: TDateTime;
AverageSpeed: Double;
begin
//Errechnen der Transfergeschwindigkeit:
TotalTime := Now - STime;
DecodeTime(TotalTime, H, M, Sec, MS);
Sec := Sec + M * 60 + H * 3600;
DLTime := Sec + MS / 1000;
if DLTime > 0
then
AverageSpeed := (AWorkCount / 1024) / DLTime;
S := FormatFloat('
0.00 KB/s', AverageSpeed);
case AWorkMode
of
wmRead: StatusBar1.Panels[0].Text := '
Download speed ' + S;
wmWrite: StatusBar1.Panels[0].Text := '
Uploade speed ' + S;
end;
//Aktualisieren der Fortschrittsanzeige:
ProgressBar1.Position := AWorkCount;
end;
end.