英文:
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 := '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?
答案1
得分: 1
我按照@istepaniuk的建议完成了这个操作。
我还学会了如何在IDE中跟踪单元代码,以尝试导入单元并查找类型声明。
-
将这个添加到
uses
列表中:IdFTPList
-
将代码行更改为:
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
-
Added this to the
uses
listIdFTPList
-
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论