Resolve method unavailable on WinSCP.ComparisonDifference

Advertisement

BruceVS
Joined:
Posts:
2

Resolve method unavailable on WinSCP.ComparisonDifference

Hi,

I'm trying to synchronise folders from remote to local using powershell, I'm using the quickstart here:
https://winscp.net/eng/docs/library_example_keep_local_directory_up_to_date
I'm testing it using powershell ISE as admin.
I've downloaded the latest release of the winscp automation zip, however I'm getting the below error when trying to call Resolve:
Method invocation failed because [WinSCP.ComparisonDifference] does not contain a method named 'Resolve'.

I don't think this is a .Net version issue as it creates and connects the session fine.
I've also tried the net4 and netstandard2 subdirectories for the binary. Both connect fine to the remote server and list contents etc, but both give the same 'Resolve' not available error.

Sample of the important bits, its straight from the quickstart:
try
{
    # Load WinSCP .NET assembly
    Add-Type -Path "D:\Job Data\Temp\Alpha\WinSCP-Automation\netstandard2.0\WinSCPnet.dll"
 
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
            Protocol = [WinSCP.Protocol]::Ftp
            HostName = "xxx"
            UserName = "xxx"
            Password = "xxx"
            FtpSecure = [WinSCP.FtpSecure]::Implicit
            TlsHostCertificateFingerprint = "xxx"
    }
    $session = New-Object WinSCP.Session
    try
    {
        # Connect
        $session.Open($sessionOptions)
 
        $remote = "/Index Data"
        $local = "D:\Job Data\Temp\Alpha\Index Data"
        $differences = $session.CompareDirectories([WinSCP.SynchronizationMode]::Local, $local, $remote, $true)
 
        Write-Host
        if ($differences.Count -eq 0)
        {
            Write-Host "No changes found."   
        }
        else
        {
            Write-Host "Synchronizing $($differences.Count) change(s)..."
            
            foreach ($difference in $differences)
            {
                try
                {
                    $difference.Resolve($session) | Out-Null
                    Write-Host " Done."
                    
                }
                catch
                {
                    Write-Host
                    HandleException $_
                }
            }
        }
    }
    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
 
    exit 0
}
catch
{
    Write-Host "Error: $($_.Exception.Message)"
    exit 1
}

Please could someone point out what I did wrong?
Thanks,

Reply with quote

Advertisement

BruceVS
Joined:
Posts:
2

Just an update, after spending a full day trying to work out how to use the differences and synchronisation methods effectively, I've realised they don't do what i need them to.
The magic "Resolve" doesn't exist, and if the rest doesn't give errors, then the behaviour is not what I actually needed.
All I need to do is synchronise a local folder to be the same as whats on the remote folder, but the remote folder includes much nested subdirectories.

I'll still use WinSCP for enumerating folders & files and downloading the files only.
All the rest of the local file structure management I'm doing manually and I'll post here when done, just in case it helps someone else in the future.

Reply with quote

Advertisement

You can post new topics in this forum