OnDirectoryList.FileInfo.FileType is always ftUnknown

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
dcornelius
Posts: 7
Joined: Tue 06 Aug 2013 19:24
Location: Portland, Oregon, USA
Contact:

OnDirectoryList.FileInfo.FileType is always ftUnknown

Post by dcornelius » Wed 29 Jan 2014 17:03

While listing the files in a download directory, I want to check the file type and skip directories. Since the OnDirectoryList event fills a FileInfo parameters, I tried checking the Attributes. I can read the Size and ModifyTime, but the FileType is always ftUnknown. I tried calling RetrieveAttributes and got the same thing.

Is this information just not available on some systems? How does a separate SFTP utility program know the difference between folders and files?

The SFTP server is running SSH 2.0 and SFTP 3.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Re: OnDirectoryList.FileInfo.FileType is always ftUnknown

Post by Dimon » Fri 31 Jan 2014 14:42

The point is that ReadDirectory sets only received from SFTP server TScSFTPFileAttributes properties. If you use SFTP protocol version 3, the FileType property is not set, because this attribute is not supported. The FileType property is returned by SFTP server with protocol version 4 and higher.
To solve the issue you can check the FileInfo.Longname property, like in SFTPClient Demo of SecureBridge.

dcornelius
Posts: 7
Joined: Tue 06 Aug 2013 19:24
Location: Portland, Oregon, USA
Contact:

Re: OnDirectoryList.FileInfo.FileType is always ftUnknown

Post by dcornelius » Thu 06 Feb 2014 16:22

Thanks. Using the Longname field, I can get the read, write, execute, and directory markers in the unix format. So I can use this to easily detect folders. In fact, it's so obvious that I wonder why I didn't see this before--and why the components couldn't do this for me.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Re: OnDirectoryList.FileInfo.FileType is always ftUnknown

Post by Dimon » Fri 07 Feb 2014 13:29

Feel free to contact us if you have any further questions about SFTP.

Post Reply