Registriert seit: 26. Mai 2004
3.159 Beiträge
|
AW: FTP Fehler Fenster nicht anzeigen
14. Jul 2011, 20:33
Schau dir mal try-except und try-finally an Guckst du hier.
Delphi-Quellcode:
procedure TFormSys.BtFTPClick(Sender: TObject);
begin
BtSpeichern.Click;
IdFTP1.Host:= ' ***';
IdFTP1.Port:= (21);
IdFTP1.Username:= ' ***';
IdFTP1.Password:= ' ***';
try
IdFTP1.Connect;
except
on E : Exception do
begin
LabelError.Caption := ' Could not connect to server: ' + E. Message;
Exit;
end;
end;
try
try
IdFTP1.Put(ExtractFilePath(ParamStr(0)) +' Systeminfos '+ GetUsername + ' .txt',
ExtractFileName(' Systeminfos '+ GetUsername + ' .txt'));
except
on E : Exception do
begin
LabelError.Caption := ' Could not put data to server: ' + E. Message;
end;
end;
finally
IdFTP1.Disconnect;
end;
end;
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
Geändert von s.h.a.r.k (14. Jul 2011 um 20:42 Uhr)
|