Re: Can't get attributes of file
WinSCP needs to be able to retrieve attributes of a file to download it. At least to know if that "name" is a file or a folder.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Please attach a log file from GUI showing a successful download of the same file.
Error: Can't get attributes of file '/incoming/Metasys/metasys.zip'.
File or folder '/incoming/Metasys/metasys.zip' does not exist.
try
{
# Load WinSCP .NET assembly
Add-Type -Path $WinSCPdllPath
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::FTP
FtpMode = [WinSCP.FtpMode]::Passive
HostName = $HostName
UserName = $UserName
Password = $Password
}
$session = New-Object WinSCP.Session
$session.SessionLogPath = "c:\Temp\WinSCP.log"
try
{
# Connect
$session.Open($sessionOptions)
# Upload files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.PreserveTimeStamp = $True
$transferResult = $session.GetFiles($($FTPPath + "metasys.zip"),$LocalPath, $False, $transferOptions)
# Throw on any error
$transferResult.Check()
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch [Exception]
{
Write-Host ("Error: {0}" -f $_.Exception.Message)
exit 1
}