Re: List() problems and fileExists() solution.

Giganews Newsgroups
Subject: Re: List() problems and fileExists() solution.
Posted by:  Remy Lebeau (TeamB) (
Date: Sun, 8 Aug 2004

"David Goadby" <dav…> wrote in message

> If the file does not exist then I get an exception:
>    EIdProtocolReplyError with Message:
> " testfilename: No such file or directory"  -
> not what I expected.

Actually, it should be exactly what you should expect, because that is how
the FTP protocol works.  You requested information about a specifc file, and
the file did not exist, so the FTP server returned an error as such.

> I am confused by the inconsistency of the results with detail
> True/False as I expected the lists to be the same except with,
> or without, the detail.

Any inconsistencies are a result of the FTP server itself, not TIdFTP or
List().  It is the server who processes the request and returns the
requested directory/file information.  Most FTP servers simply pipe the LIST
and NLIST commands to the file system directly, and then pipe the file
system's response data back to the client.  There are numerous file systems
being used around the world, and even more command-line directory/file
listing utilities on top of the file system.  That is why Indy 10 has dozens
of FTP listing parsers now - simply because FTP directory/file listings are
*NOT* standardized at all.

> I haven't had time to research further but at least I have been
> able to make my FileExists(testfilename) function work by using :

Here is an alternative approach:

    var bExists: Boolean;
        IdFTP1.List(nil, testfilename, False);
        bExists := (IdFTP1.ListResult.Count > 0);
        bExists := False;



In response to

List() problems and fileExists() solution. posted by David Goadby on Sun, 8 Aug 2004