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

aksarben

Re: Extraneous Console Output Interfering with Progress Bar

Ok. Thanks.
martin

Re: Extraneous Console Output Interfering with Progress Bar

That has nothing to do with WinSCP .NET assembly.
That's simply how PowerShell works. If a statement yields a result, PowerShell dumps it to a console. If you do not want to that (and you are not interested in the result), a common pattern is to pipe the result to Out-Null:
$session.PutFileToDirectory($fileName, $folder, $remove, $options) | Out-Null
aksarben

Extraneous Console Output Interfering with Progress Bar

Found the cause. According to https://winscp.net/forum/viewtopic.php?t=24979, the output is a JSON representation of TransferEventArgs. It was apparently triggered by the following line in my code:
$session.PutFileToDirectory($fileName, $folder, $remove, $options)

Don't know why PowerShell thought that line required output, since it’s like many of the examples I’ve seen. In any case, I simply declared a [WinSCP.TransferEventArgs]$result object elsewhere, prepended it to the above code line, and voila! The problem disappeared.

Bothersome that I don't understand why such a seemingly innocent line of code would cause that kind of problem. Ah well…

When I transfer, extraneous output is written to the console, and is interfering with my progress bar. I can't figure out where this output is coming from. It looks like this, written for each file:
Side        : Local

Destination : /bib\w/wright.htm
Length      : 571
Touch       : WinSCP.TouchEventArgs
Chmod       :
Removal     :
FileName    : C:\Users\John\Documents\tch\ssh\client\bib\w\wright.htm
Error       :

Is the .NET Assembly creating this output? How do I stop it?