Enumerate Remote Files

Advertisement

tonysut@gmail.com
Joined:
Posts:
1
Location:
USA

Enumerate Remote Files

Hey guys. Awesome product.
I'm using this in C# to pull down files from a remote ftp on a daily basis.
My question is this, when enumerating the remote folder, subfolders and files, i'm having an issue where the results don't always include the folder names. (I.e. having iSDirectory set)

For example, when the
 lastModifiedEndDate = DateTime.Now.AddDay(0)
everything works as expected. I can loop through the results and using .IsDirectory see which entries are directories and which ones are files.

However, using anything other than 0 (today), it will return files, but not directory names.
For example
 lastModifiedEndDate = DateTime.Now.AddDay(-1) (Today minus 1 day)
folder names are excluded.

I suspect this is because, as new files get added to these directories everyday, the folder will always have a timestamp for the current day and that is why they do not get included in the result set when filtering on older date ranges.

I hope this makes sense. I need to pull back subfolder names every time regardless of date filtering.
I don't want to exclude the folder names from my results, just exclude them from the date filtering.

EnumerationOptions eOptions = EnumerationOptions.AllDirectories | EnumerationOptions.EnumerateDirectories;

fileInfos = session.EnumerateRemoteFiles(argsSettings.filePaths.remoteFolder, null, eOptions).Where(file => ((file.LastWriteTime.Date >= lastModifiedStartDate.Date) && (file.LastWriteTime.Date <= lastModifiedEndDate.Date)));

Thanks,
Tony

Reply with quote E-mail

Advertisement

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

Re: Enumerate Remote Files

.Where(file => file.IsDirectory || ((file.LastWriteTime.Date >= lastModifiedStartDate.Date) && (file.LastWriteTime.Date <= lastModifiedEndDate.Date)));

Reply with quote

Advertisement

You can post new topics in this forum