WInSCP Copies subdirectories, even with the exclude FileMask

Advertisement

jerryhanel
Guest

WInSCP Copies subdirectories, even with the exclude FileMask

I am using Version 1.1.4.3839 of the WinSCPnet.dll. In my code, I have the following lines:

TransferOptions tOpts = new TransferOptions();
tOpts.FileMask = "*/";

TransferOperationResult res = sess.PutFiles("S:\\TRANSFER_ME\\*.csv", c.RemotePath, false, tOpts);


Using this code, it SHOULD copy only the root level CSV files. Instead, it copies all CSV files, including those in the "processed" subfolder, which I don't want it to do. Is there any way to copy only the files and not subfolders?? I do not want to copy recursively.

Reply with quote

Advertisement

jerryhanel
Guest

I found the answer

The answer is in the file mask, but the documentation doesn't have it exactly correct. The Exact answer is actually in the footnotes of the documentation page, not in the main documentation page.

FileMask consists of file patterns on two sides of a pipe character. If no pipe character is included, it is assumed to all be left-hand side.

(include masks) | (exclude masks)

When I was doing exactly as the docs said, I was explicitly declaring an INCLUDE mask, not an EXCLUDE mask. Changing my filemask to :

tOpts.FileMask = c.SearchPattern + "|*/";

solved the issue.

Reply with quote

Advertisement

You can post new topics in this forum