This project is read-only.

How to preserve LastWriteTime when upload/download files

Sep 21, 2011 at 11:27 PM

Hello,

I'm new using SSHNET. Do you have an option to preserve file's LastWriteTime while uploading or downloading please ?

The remote server could be in a different time zone.

Thanks !

Xavier

Sep 28, 2011 at 2:45 PM

I am not sure about preserving file LastWriteTime but some options, or actually attributes can be set.

Currently LastWriteTime set as read only but internally it can be change, in theory.

So if I its possible I will make the changes and it will be available in next release on you can always check "Source Code" tab for latest code.

 

Hope it helps,

Thanks,

Oleg

Sep 28, 2011 at 3:18 PM

Just checked in code that will allow you to update LastWriteTime and LastAccessTime properties.

Here is an example on how to do it:

            using (var sftp = new SftpClient(connectionInfo))
            {
                sftp.Connect();
                var f = sftp.Get("test");
                f.LastWriteTime = DateTime.Now.AddDays(-60);
                f.LastAccessTime = DateTime.Now.AddDays(-90);
                f.UpdateStatus();
                sftp.Disconnect();
            }

Let me know if you have any further questions.

Thanks,

Oleg

Sep 30, 2011 at 10:43 AM

Hi Oleg

It works fine!

I really appreciate your job ! Thanks !

Could we have access to LastWriteTimeUtc (which exists in System.IO.FileInfo) in the class SftpFile (in order to manage the different  time zone between local et remote) ?

Regards

Xavier

Nov 22, 2011 at 3:00 AM

I just added those properties in 12361 change set.

 

Thanks,

Oleg