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

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

Hi;

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?

Regards

Applies to: Rebex SFTP

1 Answer

0 votes
answered Dec 16, 2016 by Lukas Pokorny (81,490 points)

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

Sample code:

using (var sftp = new Sftp())
{
    sftp.Connect("test.rebex.net");
    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");
}
...