Topic "WInSCP Copies subdirectories, even with the exclude FileMask"

Author Message


I am using Version 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.


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.

You can post new topics in this forum


What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License