My Code (before you ask)

Giganews Newsgroups
Subject: My Code (before you ask)
Posted by:  mojoala (jwarr…@jimbishopcabinets.com)
Date: Wed, 19 Dec 2007

function TfrmMain.fDownloadAFile( InFileName : String ) : boolean;
var
  Directory : String;
begin
  Result := False;
  //Are we connected
  try
    if IdFTP1.Connected then
      begin
        //Always Binary for files like Advantage
        IdFTP1.TransferType := ftBinary;
        //Default Directory
        Directory := DMJBCRoutines.fGetAliasDirectory('JBCFTP');
        Directory := DMJBCRoutines.fNeedBackSlash(Directory);
        IdFTP1.Get( InFileName, Directory + InFileName, True{Overwrite} );
        Result := True;
      end
    else
      pShowStatus('Unable to Download - Not Connected!');
  except
    on E: Exception do
    begin
      DMProgLog.pWriteDebug( 'XM-Down', 'Error Saving: ' +
                InFileName + ' - ' + E.Message );
    Result := False;
    end;
  end;
end;

I HAVE SINCE CHANGED THE CODE

function TfrmMain.fDownloadAFile( InFileName : String ) : boolean;
var
  Directory : String;
  i : integer;
  FileSaved : Boolean;
begin
  FileSaved := False;
  for i := 1 to 10 do
    begin
      TRY
        if IdFTP1.Connected then
          begin
            IdFTP1.TransferType := ftBinary;
            Directory := DMJBCRoutines.fGetAliasDirectory('JBCFTP');
            Directory := DMJBCRoutines.fNeedBackSlash(Directory);
            DMProgLog.pWriteDebug( 'XM-Down', Getting ' + InFileName);
            IdFTP1.Get( InFileName, Directory + InFileName,
True{Overwrite} );
            FileSaved := True;
            Break;
          end
        else
          begin
              pShowStatus('Unable to Download - Not Connected!');
              DMProgLog.pWriteDebug( 'XM-Down',  'Not Connected');
              IdFTP1.Connect;
        end;
      EXCEPT
        on E: Exception do
            begin
                  DMProgLog.pWriteDebug( 'XM-Down', 'Error Saving: ' +
InFileName);
                  DMProgLog.pWriteDebug( 'XM-Down', E.Message );
                  IdFTP1.Connect;
            end;
      END;
    end;
end;

Replies

None

In response to

Socket Error 10054 ( Indy 9 to Indy 10 ) posted by mojoala on Wed, 19 Dec 2007