GetFiles Not Throwning Exception
WinSCP 5.1.7.0
windows Server 2003 R2 with SP2
Sftp
Scripting / Automating
Downloading a file from a remote directory does not throw an exception when the file does not exist.
Here's the result from the PowerShell window:
PS C:\WINDOWS\system32\WindowsPowerShell\v1.0> C:\scripts\labQCFileDownload.ps1
Transfers Failures IsSuccess
--------- -------- ---------
{} {} True
Another user in .NET assembly / COM library (https://winscp.net/forum/viewtopic.php?t=12773) is experiencing the same issue with putFiles, but I don't know what version of WinSCP he's running.
windows Server 2003 R2 with SP2
Sftp
Scripting / Automating
Downloading a file from a remote directory does not throw an exception when the file does not exist.
Here's the result from the PowerShell window:
PS C:\WINDOWS\system32\WindowsPowerShell\v1.0> C:\scripts\labQCFileDownload.ps1
Transfers Failures IsSuccess
--------- -------- ---------
{} {} True
Another user in .NET assembly / COM library (https://winscp.net/forum/viewtopic.php?t=12773) is experiencing the same issue with putFiles, but I don't know what version of WinSCP he's running.
try { # Load WinSCP .NET assembly # Use "winscp.dll" for the releases before the latest beta version. [Reflection.Assembly]::LoadFrom("\\C:\scripts\WinSCP.dll") | Out-Null # Setup session options $sessionOptions = New-Object WinSCP.SessionOptions $sessionOptions.Protocol = [WinSCP.Protocol]::Sftp $sessionOptions.HostName = "xxxxxxxx" $sessionOptions.UserName = "xxxxxxxx" $sessionOptions.Password = "xxxxxxxx" $sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 0e:2b:76:24:bf:50:e7:29:f5:01:2b:e6:59:16:ea:10" $session = New-Object WinSCP.Session $session.AdditionalExecutableArguments = "/xmllog='c:\temp\lab_qc_log.xml'" $session.DebugLogPath = "c:\temp\lab_qc_debug.log" $session.SessionLogPath = "c:\temp\lab_qc_session.log" $session.XmlLogPath = "c:\temp\lab_qc_sessionxml.xml" $session.ExecutablePath = "c:\scripts\winscp.exe" try { # Connect $session.Open($sessionOptions) $stamp = Get-Date -f "yyyyMMdd" $fileDay = Get-Date -Format "dd" $fileName = "FTP20*" $remotePath = "/U/softprint/$fileName" $localPath = "c:\lab_qc\$fileName" $session.GetFiles($remotePath, $localpath) } catch [Exception] { Write-Host $_.Exception.Message } finally { # Disconnect, clean up $session.Dispose() } exit 0 } catch [Exception] { Write-Host $_.Exception.Message exit 1 }