Session.CompareDirectories Method

Compares directories, the same way Session.SynchronizeDirectories method does, but returns differences only.

Syntax

C#
public ComparisonDifferenceCollection CompareDirectories(
    SynchronizationMode mode,
    string localPath,
    string remotePath,
    bool removeFiles,
    bool mirror = false,
    SynchronizationCriteria criteria = SynchronizationCriteria.Time,
    TransferOptions options = null
)
VB.NET
Public Function CompareDirectories(
    mode As SynchronizationMode,
    localPath As String,
    remotePath As String,
    removeFiles As Boolean,
    Optional mirror As Boolean = False,
    Optional criteria As SynchronizationCriteria = SynchronizationCriteria.Time,
    Optional options As TransferOptions = Nothing
) As ComparisonDifferenceCollection

Parameters

Name Description
SynchronizationMode mode Synchronization mode. Possible values are SynchronizationMode.Local, SynchronizationMode.Remote and SynchronizationMode.Both.
string localPath Full path to local directory.
string remotePath Full path to remote directory.
bool removeFiles When set to true, considered obsolete files to be deleted. Cannot be used for SynchronizationMode.Both.
bool mirror When set to true, compares in mirror mode (synchronizes also older files). Cannot be used for SynchronizationMode.Both. Defaults to false.
SynchronizationCriteria criteria Comparison criteria. The parameter is a bit field of any of SynchronizationCriteria.Time (default), SynchronizationCriteria.Size and SynchronizationCriteria.Checksum. SynchronizationCriteria.None can be used as an alias to empty bit field. For backward compatibility, SynchronizationCriteria.Either can be used as an alias to Time | Size. For SynchronizationMode.Both, SynchronizationCriteria.Time can be used only.
TransferOptions options Transfer options. Defaults to null, what is equivalent to new TransferOptions(). Only few properties matter for comparison, notably the TransferOptions.FileMask.

Return Value

ComparisonDifferenceCollection – a read-only collection of differences. See ComparisonDifference.

Exceptions

Exception Condition
InvalidOperationException Session is not opened.
ArgumentException
ArgumentOutOfRangeException
Invalid combination of values of TransferOptions properties, SynchronizationMode, mirror or SynchronizationCriteria.
SessionLocalException Error communicating with winscp.com.
See the exception documentation for details.
SessionRemoteException Session has failed.
Listing of remote directories has failed.
See the exception documentation for details.
TimeoutException Timeout waiting for winscp.com to respond.

Examples

Real-Life Examples

Last modified: by martin