0 votes
by (210 points)
edited

Hello, When I retrieve and display the list of files and directories, I use this code

  SftpItemCollection list = client.GetList();
  foreach (SftpItem item in list)
  {
      if (item.IsFile)
      {
          ...

but when I try to access to item.Created property the result is always, for all files, "01/01/1970 00:00:00". Why?

Applies to: Rebex SFTP

3 Answers

+1 vote
by (147k points)
edited

Creation time is only reported by SFTP servers which use SFTP v4 and later. However, the majority of SSH/SFTP servers in use only support SFTP v3 (the most notable example is OpenSSH, whose developers don't have any plans to support it).

To check whether your server supports SFTP v4, use Sftp object's ProtocolVersion property.

Please note that SftpItem.Created property is obsolete and has been replaced with SftpItem.CreationTime property, which (unlike SftpItem.Created) returns nullable DateTime, making it possible to easily detect 'not available' results (unlike SftpItem.Created, which uses zero Unix time - "01/01/1970 00:00:00" - to indicate the same).

0 votes
by (210 points)
edited

Thanks for response.

0 votes
by (210 points)
edited

I used build 4060 and in this version not exist CreationTime property. Now I download 2012R2 Version and I have a that property, but is null. I used ssh sftp server on WinXP (virtualbox machine)

by (58.9k points)
edited

The SFTP server you are using does not support SFTP protocol version 4. CreationTime property is only supported by servers which support SFTP version 4. If they only support version 3, the CreationTime property will be null. I suggest that you try to install a SFTP server which supports version 4 ( e.g. http://dl.bitvise.com/BvSshServer-Inst.exe ).

...