Search code examples
delphiindy

Delphi IdFTP: how to check type of file entry?


I actually did this

FTP.Connect;
FTP.Login;
FTP.List;
StatusBar.Panels[0].Text := 'Connessione FTP riuscita';
For I := 0 to FTP.DirectoryListing.Count - 1 do
begin


  if (FTP.DirectoryListing[I].ItemType <> ditFile) then continue;

  lstFTPFiles.Items.Add(FTP.DirectoryListing[I].FileName + #9        )
end;

Note the line

if (FTP.DirectoryListing[I].ItemType <> ditFile) then continue;

I atually get the error

E2003: Undelcared identifier: ditFile

I see this syntax here https://stackoverflow.com/a/23158116/1055279

Should I use or declare something to be able to use this constant?


Solution

  • I ended doing this (as suggested from @istepaniuk).

    I learned also how to follow unit code in the IDE to try the unit to import and find type declarations

    1. Added this to the uses list

      IdFTPList
      
    2. Changed the line as

      if (FTP.DirectoryListing[I].ItemType <> TIdDirItemType.ditFile)
      

    I don't know if there is a more idiomatic and short way to perform same task.