Delphi IdFTP:如何检查文件条目的类型?

huangapple go评论58阅读模式
英文:

Delphi IdFTP: how to check type of file entry?

问题

我实际上做了这个

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;

请注意这一行

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

我实际上得到了错误

E2003: Undelcared identifier: ditFile

我在这里看到了这个语法 https://stackoverflow.com/a/23158116/1055279

我应该use或声明一些东西才能使用这个常量吗?

英文:

I actually did this

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


  if (FTP.DirectoryListing[I].ItemType &lt;&gt; ditFile) then continue;

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

Note the line

if (FTP.DirectoryListing[I].ItemType &lt;&gt; 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?

答案1

得分: 1

我按照@istepaniuk的建议完成了这个操作。

我还学会了如何在IDE中跟踪单元代码,以尝试导入单元并查找类型声明。

  1. 将这个添加到uses列表中:

    IdFTPList
    
  2. 将代码行更改为:

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

我不知道是否有更符合惯用法且更简洁的方法来执行相同的任务。

英文:

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 &lt;&gt; TIdDirItemType.ditFile)
    

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

huangapple
  • 本文由 发表于 2023年6月6日 16:29:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76412779.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定