procedure TForm1.Button1Click(Sender: TObject);
var
AFiles:TStringList;
begin
if IdFTP1.Connected then try
if TransferrignData then IdFTP1.Abort;
statusbar1.SimpleText :='断开连结!';
button2.Enabled :=false;
button5.Enabled :=false;
IdFTP1.Quit;
finally
Edit5.Text := '/';
ListBox1.Items.Clear;
memo1.Clear ;
Button1.Caption := '连接';
end
else with IdFTP1 do try
User := Edit3.Text;
Password := Edit4.Text;
Host := Edit1.Text;
port := strtoint(edit2.Text );
Connect;
ChageDir(Edit5.Text);
finally
if Connected then begin
statusbar1.SimpleText :='连接成功!';
Button1.Caption := '断开连结';
listbox1.Items.Clear;
memo1.Clear ;
AFiles := TStringList.Create;
idftp1.List(afiles,'', false);
listbox1.items.AddStrings(afiles);
afiles.Free;
button2.Enabled :=true;
button5.Enabled :=true;
end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
if button2.Caption='上传文件' then
begin
IdFTP1.TransferType := ftBinary;
button2.Caption :='停止上传';
memo1.Clear ;
for i:=0 to (filelistbox1.Items.Count -1) do
begin
if listbox1.Items.IndexOf(filelistbox1.Items)<0 then
begin
idftp1.Put(filelistbox1.Items,filelistbox1.Items,false);
memo1.Lines.Add (filelistbox1.Items);
application.processmessages;
end;
end;
idftp1.Abort ;
button2.Caption:='上传文件';
end
else
begin
memo1.Clear ;
idftp1.Abort ;
button2.Caption:='上传文件';
end;
end;