0

We have a sync process that is daily making sure we have all files from a remote SFTP but as time goes on, we're having to download all files just to check that we already file copies in the database by content hash.

Is there a way, let's say using SSH.NET or WinSCP, to only do this process with files in the last two weeks?

Farhad Zamani
  • 5,381
  • 2
  • 16
  • 41
djbyter
  • 763
  • 8
  • 28

1 Answers1

0

I'd use FluentFTP

using FluentFTP;
using System.Linq;

.
.
.

DateTime min = ...;
DateTime max = ...;

using (var conn = new FtpClient("address", "user", "password"))
{
    conn.Connect();

    var files = conn
        .GetListing("/path", FtpListOption.Recursive)
        .Where(item => item.Type == FtpFileSystemObjectType.File
                    && item.Modified >= min
                    && item.Modified <= max);

    foreach(var file in files)
    {
        ...
    }
}

You can use Created instead of Modified

opekope2
  • 48
  • 7
  • While OP is indeed bit inconsistent about the use of SFTP and FTP terms, I believe he actually wants to use SFTP, not FTP. So FluentFTP won't help. – Martin Prikryl May 28 '20 at 18:23