this slowpoke moves

FTP Upload with ProgressBar

uses IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdFTP, IdAntiFreezeBase, IdAntiFreeze, ComCtrls
  
//

procedure TForm1.Button1Click(Sender: TObject);
begin
  IdFTP1.Host := Edit1.Text;   // Server
  IdFtp1.Username := Edit2.Text; // User
  IdFTP1.Password := Edit3.Text; // Password
  IdFTP1.Connect;
  IdFTP1.ChangeDir(Edit5.Text);
  IdFTP1.Put(Edit4.Text, ExtractFilename(Edit4.Text)); // File
  IdFTP1.Disconnect;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
    Edit4.Text := OpenDialog1.FileName;
end;

procedure TForm1.IdFTP1Status(ASender: TObject; const AStatus: TIdStatus;
  const AStatusText: String);
begin
  Statusbar1.SimpleText := AStatusText;
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.IdFTP1Work(Sender: TObject; AWorkMode: TWorkMode;
  const AWorkCount: Integer);
begin
  ProgressBar1.Position := AWorkCount;
  Application.ProcessMessages;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate