Page 1 of 1

OnDirectoryList.FileInfo.FileType is always ftUnknown

Posted: Wed 29 Jan 2014 17:03
by dcornelius
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.

Re: OnDirectoryList.FileInfo.FileType is always ftUnknown

Posted: Fri 31 Jan 2014 14:42
by Dimon
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.

Re: OnDirectoryList.FileInfo.FileType is always ftUnknown

Posted: Thu 06 Feb 2014 16:22
by dcornelius
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.

Re: OnDirectoryList.FileInfo.FileType is always ftUnknown

Posted: Fri 07 Feb 2014 13:29
by Dimon
Feel free to contact us if you have any further questions about SFTP.