I have a script which is transferring some files via SFTP using WinSCP.
A summary of the script:
$transferfiles = @("filename 1" "filename 2")
foreach ($file in $transferfiles) {
$file
$transferResult = $session.PutFiles($file, "/upload/TEST/", $False,$transferOptions)
try {
$transferResult.Check()
}
catch [Exception]{
Write-Host "$file was not transferred."
}
}
I just want to know if I need to use [Exception]
? Why doesn't catch
by itself work?
Thanks
catch [Exception]
is identical to catch
.
So you do not need to use catch [Exception]
.
I have modified all official WinSCP .NET assembly examples to use just catch
.