Download with "Get" doesn't work

Giganews Newsgroups
Subject: Download with "Get" doesn't work
Posted by:  Antonio Cambule (Stüber Software) (anton…@stueber.de)
Date: Wed, 06 Jul 2005

Hello,

I try to establish an FTP Connection to an FTP Server and to download
an file. Connection seems to be ok but when I step through the GET
Method it walks into

idIOHandler.pas
  --> raise EIdConnClosedGracefully.Create(RSConnectionClosedGracefully);

  above there is this comment:

{
If this is a CLIENT
-------------------
The server side of this connection has disconnected normaly but your
client has attempted to read or write to the connection. You should trap
this error using a try..except. Please see the help file for possible
further information. }

If you take look at the code you will see that there is an
try..except block but it doesn't run into.

I've taken a look a an FTP Client sample and couldn't find differences
that seem to cause this problem.

Anyone an Idea?

regards
Antonio Cambule

CODE:
-----------

      { URI is an FTP-Address }
      if CompareText(Package.Protocol, 'Ftp') = 0 then
      begin
        AntiFreeze := TIdAntiFreeze.Create(Self);
        try
          FtpClient := TIdFtp.Create(Self);
          try

            { Registerkarte Ftp Download anzeigen }
            PageControl.ActivePage := tshFtpDownload;

            { Dateiname für temporäres Update Package generieren }
            TmpPackageFileName := FilePath.Combine(FilePath.GetTempPath,
              Configuration.Package.Document);

            { Ftp Client initialisieren }
            FtpClient.Host := Package.Host;
            FtpClient.Port := StrToIntDef(Package.Port, IdPORT_Ftp);
            FtpClient.UserName := AssignStr(Package.UserName,     
                                        'anonymous');
            FtpClient.Password := Package.Password;
            FtpClient.Passive := true;
            FtpClient.TransferType := ftBinary;
            FtpClient.OnWorkBegin := FtpWorkBegin;
            FtpClient.OnWorkEnd := FtpWorkEnd;
            FtpClient.OnWork := FtpWork;

            try

              { Ftp Download durchführen }
              FtpClient.Connect;
              try
                FtpClient.ChangeDir(Package.Path);
                FtpClient.Get(Package.Document, TmpPackageFileName,
                  true);
              finally
                FtpClient.Disconnect;
              end;

              { Is Download been canceled by User? }
              if UserAbort then
              begin

                { Get AbortError Message }
                lblErrorMessage.Caption := SUserAbort;

                { Show Error }
                PageControl.ActivePage := tshError;

              end else
              begin

                { All OK }
                PageControl.ActivePage := tshFtpReady;

              end;

            except
              on E: Exception do
              begin

                { Get ErrorMessage }
                lblErrorMessage.Caption := E.Message;

                { Show Error }
                PageControl.ActivePage := tshError;

              end;
            end;

          finally
            FreeAndNil(FtpClient);
          end;
        finally
          AntiFreeze.Free
        end;
      end else

Replies