unit U_FTPClient;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdExplicitTLSClientServerBase, IdFTP, StdCtrls, ComCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Login_Button: TButton;
DirectoryListBox: TListBox;
Button_Logout: TButton;
Button_Ordnerloeschen: TButton;
Button_Ordnererstellen: TButton;
IdFTP1: TIdFTP;
UserIDEdit: TEdit;
PasswordEdit: TEdit;
FtpServerEdit: TEdit;
StatusBar1: TStatusBar;
Edit_AktuellerOrdner: TEdit;
Label1: TLabel;
Edit_Ordnererstellen: TEdit;
Edit_Ordnerloeschen: TEdit;
Edit_DateiDownloaden: TEdit;
Edit_Dateiloeschen: TEdit;
Button_Dateiloeschen: TButton;
ProgressBar1: TProgressBar;
SaveDialog1: TSaveDialog;
Button_DateiDownloaden: TButton;
Button_Dateiuploaden: TButton;
OpenDialog1: TOpenDialog;
E_Ordneroeffnen: TEdit;
Button_Ordneroeffnen: TButton;
procedure Button_DateiuploadenClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button_DateiDownloadenClick(Sender: TObject);
procedure IdFTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: Integer);
procedure Button_OrdnererstellenClick(Sender: TObject);
procedure Button_DateiloeschenClick(Sender: TObject);
procedure Button_OrdnerloeschenClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button_LogoutClick(Sender: TObject);
procedure Login_ButtonClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Dateiname:
string;
Dateinameu:
string;
implementation
{$R *.dfm}
procedure TForm1.Login_ButtonClick(Sender: TObject);
begin
IdFTP1.Username := UserIDEdit.Text;
IdFTP1.Password := PasswordEdit.Text;
IdFTP1.Host := FtpServerEdit.Text;
IdFTP1.Connect;
IdFTP1.List(DirectoryListBox.Items);
Edit_AktuellerOrdner.Text := '
/';
Button_Logout.Enabled := True;
Button_Ordnererstellen.Enabled := True;
Button_Ordnerloeschen.Enabled := True;
Button_Ordneroeffnen.Enabled := True;
Button_Dateiloeschen.Enabled := True;
Button_DateiDownloaden.Enabled := True;
Button_Dateiuploaden.Enabled := True;
Login_Button.Enabled := False;
end;
procedure TForm1.Button_LogoutClick(Sender: TObject);
begin
IdFTP1.Quit;
Button_Logout.Enabled := False;
DirectoryListBox.Items.Clear;
DirectoryListBox.Items.Add('
Verbindung Getrennt');
Login_Button.Enabled := True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Button_Ordnerloeschen.Enabled := False;
Button_Ordnererstellen.Enabled := False;
Button_Dateiloeschen.Enabled := False;
Button_DateiDownloaden.Enabled := False;
Button_Ordneroeffnen.Enabled := False;
Button_Dateiuploaden.Enabled := False;
Button_Logout.Enabled := False;
end;
procedure TForm1.Button_OrdnererstellenClick(Sender: TObject);
begin
IdFTP1.MakeDir(Edit_Ordnererstellen.Text);
Edit_Ordnererstellen.Text := '
';
DirectoryListBox.Items.Clear;
IdFTP1.List(DirectoryListBox.Items);
end;
procedure TForm1.Button_OrdnerloeschenClick(Sender: TObject);
begin
IdFTP1.RemoveDir(Edit_Ordnerloeschen.Text);
Edit_Ordnerloeschen.Text := '
';
DirectoryListBox.Items.Clear;
IdFTP1.List(DirectoryListBox.Items);
end;
procedure TForm1.Button_DateiloeschenClick(Sender: TObject);
begin
IdFTP1.Delete(Edit_Dateiloeschen.Text);
Edit_Dateiloeschen.Text := '
';
DirectoryListBox.Items.Clear;
IdFTP1.List(DirectoryListBox.Items);
end;
procedure TForm1.IdFTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: Integer);
begin
ProgressBar1.Max := AWorkCountMax;
ProgressBar1.Position := 0;
end;
procedure TForm1.Button_DateiDownloadenClick(Sender: TObject);
begin
Dateiname := '
';
Dateiname := Edit_DateiDownloaden.Text;
if SaveDialog1.Execute
then
IdFTP1.Get(Dateiname, SaveDialog1.FileName, true);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
IdFTP1.ChangeDir(E_Ordneroeffnen.text);
Edit_AktuellerOrdner.Text := Edit_AktuellerOrdner.Text + E_Ordneroeffnen.Text;
E_Ordneroeffnen.text := '
';
DirectoryListBox.Items.Clear;
IdFTP1.List(DirectoryListBox.Items);
end;
procedure TForm1.Button_DateiuploadenClick(Sender: TObject);
begin
Dateinameu := '
';
if OpenDialog1.Execute
then
with IdFTP1
do
begin
Passive := True;
end;
IdFTP1.Put(OpenDialog1.FileName,Dateinameu, true);
DirectoryListBox.Items.Clear;
IdFTP1.List(DirectoryListBox.Items);
end;
end.