Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: How to get last n days files from SFTP Folder using C#

If you want to filter the files by time, use the RemoteFileInfo.LastWriteTime property:
https://winscp.net/eng/docs/library_remotefileinfo#lastwritetime

Like this:
session.EnumerateRemoteFiles(SFTPRootDir, FileNamePattern, EnumerationOptions.None)
    .Where(file => !file.LastWriteTime => DateTime.Now.AddDays(-N))
Vishnu_32

How to get last n days files from SFTP Folder using C#

Hi,
I'm Downloading the files from SFTP to the local folder based on the
System.Collections.Generic.IEnumerable<RemoteFileInfo> MatchedFiles =
    session.EnumerateRemoteFiles(SFTPRootDir, FileNamePattern, EnumerationOptions.None);

Here FileNamePattern is the fileMask pattern one can pass and transfer file to local path.
Here I need add one more filter like by passing last n days as variable and download last n days files.

Here client can pass either of the one filter like he can pass only FileNamePattern or last n days filter

FileNamePattern filter will be like *.txt
How can get the solution.