Combine include and exclude file mask in WinSCP .NET assembly

3k Views Asked by At

I've used the WinSCP .NET assembly to download files from my FTP for a while with a simple FileMask: "|*/", as I don't want it to traverse subdirectories. This works well, but now I'm trying to add another filemask to only download files that are have been modified after a certain date, but I'm having issues with using multiple file masks.

Writing it like this, not unexpectedly, just overwrites the FileMask property on the object:

transferOptions.FileMask = "|*/";  // don't download subdirs
transferOptions.FileMask = "*>=" + date; // only get files updated after date

and using it like this, as people have specified and how it's written in some docs:

transferOptions.FileMask = "|*/"; "*>=" + date;

gives me the error "Only assignment, call, increment, decrement, and new object expressions can be used as a statement."

Is there any other way to separate the two file masks, and make sure both are in usage?

Thanks.

1

There are 1 best solutions below

1
On BEST ANSWER

Syntax of WinSCP file mask is include|exclude.

So you want: *>=date|*/

In C# code that would be:

transferOptions.FileMask = "*>=" + date + "|*/";

See Include and exclude masks.