EnumerateRemoteFiles to get only new files

Advertisement

priram
Joined:
Posts:
2
Location:
Chantilly, VA

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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,442
Location:
Prague, Czechia

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();

Reply with quote

priram
Joined:
Posts:
2
Location:
Chantilly, VA

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.

windows date filter.PNG

Reply with quote

Advertisement

You can post new topics in this forum