Re: idFtp.Get; exception: No such file or directory

Giganews Newsgroups
Subject: Re: idFtp.Get; exception: No such file or directory
Posted by:  Remy Lebeau \(Indy Team\) (re…@lebeausoftware.org)
Date: Wed, 11 Aug 2010

"Stanislav Stoqnov" <s.stoqn…@gmail.com> wrote in message
news:A55ECA932EBAE340s.stoqn…@gmail.com...

> 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.

That is an error message from the server.  The filename being passing to the
server is not what the server is actually expecting.  Either the case is
wrong (some servers are case-sensitive), or some characters are getting
changed to other characters due to Ansi<->Unicode conversions, or the file
really does not exist (maybe something else deleted it before you call
Get()).

> Using D7 and Indy 9.00.10

That is a very old version of Indy 9.  Try upgrading to the last 9.0.50
snapshot and see if the problem continues.

> FFtp.List(nil, '*.txt', false);
>
> idx:= FFtp.ListResult.IndexOf(ChangeFileExt(FileList.Strings[0], '.txt'));

Rather than retreive the entire folder listing just to check one for file,
you could ask the server for that one file by itself instead:

{code:delphi}
OrgFile := ChangeFileExt(FileList.Strings[0], '.txt');
FFtp.List(nil, OrgFile, false);
if FFtp.ListResult.Count > 0 then
begin
  TmpFile := ChangeFileExt(OrgFile, '.tmp');
  FFtp.Get(OrgFile, FLocalFolder + TmpFile, False);
  RenameFile(FLocalFolder + TmpFile, FLocalFolder + OrgFile);
  ...
end;
{code}

--
Remy Lebeau (TeamB)

Replies

None

In response to

idFtp.Get; exception: No such file or directory posted by Stanislav Stoqnov on Wed, 11 Aug 2010