Post a reply

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: EnumerateRemoteFiles to get only new files

That does not work for me. While that filter indeed does something, it does not filter the files correctly by the date. And even if that did work, it's not Windows wildcard. Windows wildcard is what you can use on Windows command-line. Windows wildcard supports * and ? only, as documented:
https://winscp.net/eng/docs/library_session_enumerateremotefiles#fn1
priram

Re: EnumerateRemoteFiles to get only new files

Thanks @Martin. I am surprised that the method does not allow. Since it has the mask option, I thought all mask options should work.

Anyways, for filtering files in File Explorer, just enter the condition in the search. I have attached a screenshot.
martin

Re: EnumerateRemoteFiles to get only new files

Time constraints are not supported in Session.EnumerateRemoteFiles.

I wonder, how did you use that in Windows File Explorer. Show us!

Anyway, this will do:
List<RemoteFileInfo> files =
    session.EnumerateRemoteFiles(
        path, null, EnumerationOptions.AllDirectories)
        .Where(file => file.LastWriteTime >= new DateTime(2018, 4, 1))
        .ToList();
priram

EnumerateRemoteFiles to get only new files

Hi,

I am trying to retrieve only the newer files by using the mask option in EnumerateRemoteFiles as shown below and it never works.
List<RemoteFileInfo> files =
    CurrentSession.EnumerateRemoteFiles(
        path, "*>=2018-04-01", EnumerationOptions.AllDirectories).ToList();

I am not sure if there is an issue with the syntax or is it something with the method call. I have tries so many different formats and since the help document says it works similar to windows wildcard, I have tried the same on windows file explorer and it works fine. Can anyone help.

Thank you,
Priya