idFtp.Get; exception: No such file or directory

Giganews Newsgroups
Subject: idFtp.Get; exception: No such file or directory
Posted by:  Stanislav Stoqnov (s.stoqn…@gmail.com)
Date: Wed, 11 Aug 2010

Hello,

I am trying to download a file from the ftp server.
Files on the ftp exists. But sometimes I receive an exception "No such
file or directory" on FFtp.Get(...); This exception is raised offten but
not always.

Using D7 and Indy 9.00.10

My code:

FFtp.List(nil, '*.txt', false);

idx:= FFtp.ListResult.IndexOf(ChangeFileExt(FileList.Strings[0], '.txt'));

if (idx >= 0) then
begin
  OrgFile:= FFtp.ListResult.Strings[idx];
  TmpFile:= ChangeFileExt(OrgFile, '.tmp');

  FFtp.Get(OrgFile, FLocalFolder + TmpFile, False);

  if FileExists(FLocalFolder + TmpFile) then RenameFile(FLocalFolder +
TmpFile, FLocalFolder + OrgFile);

  FFtp.Delete(OrgFile);
  FFtp.ListResult.Delete(idx);
  if FLogLevel >= 2 then AddLog('Success deletion of file from FTP: ' +
OrgFile);
end;

Replies