Thema: Delphi Simple FTP

Einzelnen Beitrag anzeigen

Benutzerbild von jfheins
jfheins

Registriert seit: 10. Jun 2004
Ort: Garching (TUM)
4.579 Beiträge
 
#2

Re: Simple FTP

  Alt 14. Jun 2005, 22:54
FTP - das geht imho am besten mit Indy.

Um die Ftp-Befehle ausgeben zu lassen, habe ich mir folgende Kompo gecodet:

Delphi-Quellcode:
type
  TEventType = (etCommand, etResponse);

  TEvent = procedure (const EventText: String; EventType: TEventType) of object;

  TLogIdFtp = class (TIdFtp)
  private
    FEvent: TEvent;
  public
    procedure Write (const AOut: string = ''); override;
    function ReadLn(ATerminator: string = LF;
 const ATimeout: Integer = IdTimeoutDefault; AMaxLineLength: Integer = -1): string; override;
  published
    property OnEvent: TEvent read FEvent write FEvent;
  end;

implementation

function TLogIdFtp.ReadLn(ATerminator: string = LF;
 const ATimeout: Integer = IdTimeoutDefault; AMaxLineLength: Integer = -1): string;
begin
  Result := inherited ReadLn (ATerminator, ATimeout, AMaxLineLength);

  if Assigned (OnEvent) then
    FEvent (Trim (Result), etResponse);
end;

procedure TLogIdFtp.Write (const AOut: string);
begin
  inherited;

  if Assigned (OnEvent) then
    FEvent (Trim (AOut), etCommand);
end;
  Mit Zitat antworten Zitat