Preserve Last modified date when uploading file using FluentFtp

822 Views Asked by At

I have seen similar questions in the past but not directly related to FluentFtp NuGet package.

How can I keep the last modified date from the sender to the receiver when I am uploading a single file?

Looks like the default is not to preserve it, is there anyway of doing it manually?

1

There are 1 best solutions below

0
Martin Prikryl On

FluentFtp won't do it for you. You have to code that yourself. Use FtpClient.SetModifiedTime:

ftpClient.SetModifiedTime(remotePath, File.GetLastWriteTime(localPath));

But first, make sure your FTP server supports it. Check if any GUI/commandline FTP client can preserve timestamps of the uploaded files on your server.