Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: GetFiles TransferOptions exclusion mask not working

PiotrL wrote:

I am trying to download all files matching simple YYYYMMDD mask except *.cntl.
...
Any hints what I am doing wrong?

See https://winscp.net/eng/docs/faq_library_parameters
PiotrL

GetFiles TransferOptions exclusion mask not working

I am trying to download all files matching simple YYYYMMDD mask except *.cntl.

My YYYYMMDD mask is stored in a global [string] variable: $Global:dt
Session options (host, username, password, hostkey fprint) are stored in another global variable: $Global:sessionOptions

This is what I tried so far:

-----------------------------------------------------------------
Add-Type -Path "C:\Program Files\WinSCP Automation\WinSCPnet.dll"
$session = New-Object WinSCP.Session
$session.Open($Global:sessionOptions)
$remotePath = "/outgoing/"
$localPath = "C:\incoming\"
$topt = New-Object WinSCP.TransferOptions
$topt.FileMask = "*$Global:dt*|*cntl"
$session.GetFiles($remotePath, $localPath, $topt) | Out-Null
-----------------------------------------------------------------

The above always downloads all files matching the YYYYMMDD mask but ignoring the exclusion part of the mask (i.e. |*cntl). In other words, *YYYYMMDD*.cntl files are always downloaded. I tried to replace |*cntl with |*.cntl - no luck.

Automation library version 5.15.0
Powershell 5.1.14409.1018
Win 7 x64 Enterprise

Any hints what I am doing wrong?
paede

How do I exclude files or directories?

Hello together

I use WinSCP for long times. If I want exclude some files I can use "option exclude xyz.txt". So far so good...
Now I want use WinSCP in a new project with the COM library in C# and there I miss the exclude option in TransferOptions().
Is this option not included?

Greetings
paede