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.
OnDirectoryList.FileInfo.FileType is always ftUnknown
-
- Posts: 7
- Joined: Tue 06 Aug 2013 19:24
- Location: Portland, Oregon, USA
- Contact:
Re: OnDirectoryList.FileInfo.FileType is always ftUnknown
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.
To solve the issue you can check the FileInfo.Longname property, like in SFTPClient Demo of SecureBridge.
-
- Posts: 7
- Joined: Tue 06 Aug 2013 19:24
- Location: Portland, Oregon, USA
- Contact:
Re: OnDirectoryList.FileInfo.FileType is always ftUnknown
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
Feel free to contact us if you have any further questions about SFTP.