SFTP GetFile - How to retain original date/time file when copy

0 votes
asked Dec 13, 2016 by davidffh (120 points)


I'm evaluating Rebex SFTP for purchase, I'm downloading files and copy them in a folder but the files date/time is the current not the original in the sftp folder.

How can I retain the original date/file when copy files with GetFile i my windows folder?


Applies to: Rebex SFTP

1 Answer

0 votes
answered Dec 16, 2016 by Lukas Pokorny (97,590 points)

You can instruct Rebex SFTP to restore date/time using Sftp.Settings.RestoreDateTime property.

Sample code:

using (var sftp = new Sftp())
    sftp.Login("demo", "password");

    // restore last write time in subsequent operations
    sftp.Settings.RestoreDateTime = ItemDateTimes.LastWriteTime;

    // download the file
    sftp.GetFile("readme.txt", "readme.txt");