Can't get attributes of file

Advertisement

EricC
Guest

Can't get attributes of file

Hello,

I have write a lot of PowerShell script to download file from our customers FTP serveur.
Today one of these script dosen't work.

I can dowload the file with the GUI, but my script dosen't work.
Error: Can't get attributes of file '/incoming/Metasys/metasys.zip'.
File or folder '/incoming/Metasys/metasys.zip' does not exist.

I have made an update of WinSCPnet.dell to 5.9.3.
I have try to "GET" all "*.zip" and some other stuff...

I add below a part of my code, and i join a log to this message.

Someone have an idea?

Thanks!

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
}

Reply with quote

Advertisement

EricC
Guest

Re: Can't get attributes of file

martin wrote:

Please attach a log file from GUI showing a successful download of the same file.

Sorry for my mistake.
I can do a GUI transfert but with FileZilla.

The file i try to download is hidden, the i need the "Manual Transfer" commande to do it (I don't know if WinSCP have a similar command).

I attach a FileZilla log file from GUI showing a connection to the server and a successful download of the file.

Thanks.

Reply with quote

martin
Site Admin
martin avatar

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.

Reply with quote

Advertisement

You can post new topics in this forum