Looks like I was doing that right but it's not not turning the "preserving timestamp" option.
Here's my code:
;Define Log File
objSession.SessionLogPath = "LogFile.log"
;.Open the session using Session.Open method, passing instance of your WinSCP.SessionOptions.
; This needs more error checking as it will fail is server or ID is wrong
;ErrorMode(@OFF)
objSession.Open(objSessionOptions)
;ErrorMode(@CANCEL)
; Synchronize Directories
bFalse = ObjectType( 'BOOL', 0 )
bTrue = ObjectType( 'BOOL', 1 )
objMode = ObjectClrNew( 'WinSCP.SynchronizationMode' )
; Local direction, changes from remote directory (source) are applied to local directory (target). Only the local directory is modified.
; modeRemote = ObjectClrType( 'WinSCP.SynchronizationMode', objMode.Local )
; Remote directon, changes from the local directory (source) are applied to the remote directory (target). Only the remote directory is modified.
modeRemote = ObjectClrType( 'WinSCP.SynchronizationMode', objMode.Remote )
objCriteria = ObjectClrNew( 'WinSCP.SynchronizationCriteria' )
; File times are compared to determine which is newer.
criteriaTime = ObjectClrType( 'WinSCP.SynchronizationCriteria', objCriteria.Time )
objTransferOptions = ObjectClrNew( 'WinSCP.TransferOptions' )
objTransferMode = ObjectClrNew( 'WinSCP.TransferMode' )
objTransferOptions.TransferMode = ObjectClrType( 'WinSCP.TransferMode', objTransferMode.Binary )
objTransferOptions.PreserveTimestamp = ObjectType( 'BOOL', 0 ) ; define a BOOL datatype
SynchronizationResult = objSession.SynchronizeDirectories( modeRemote, LocalPath, remotePath, bTrue, bFalse, criteriaTime, objTransferOptions)
Here's the message from the WinSCP log file:
. 2014-03-20 13:12:09.376 Preserving timestamp [2013-08-16T19:19:14.000Z]
< 2014-03-20 13:12:09.588 Type: SSH_FXP_STATUS, Size: 44, Number: 1545
< 2014-03-20 13:12:09.588 Status code: 8, Message: 1545, Server: SSHServerAPI.SFTP.fxp_attrs, Language:
* 2014-03-20 13:12:09.588 (ETerminal) The server does not support the operation.
* 2014-03-20 13:12:09.589 Error code: 8
* 2014-03-20 13:12:09.589 Error message from server: SSHServerAPI.SFTP.fxp_attrs
. 2014-03-20 13:12:09.589 Asking user:
. 2014-03-20 13:12:09.589 **Upload of file 'WC_REPETITIVE_APAC_2013081604183644.dat' was successful, but error occurred while setting the permissions and/or timestamp.**
. 2014-03-20 13:12:09.589
. 2014-03-20 13:12:09.589 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option. ("The server does not support the operation.
. 2014-03-20 13:12:09.589 Error code: 8
. 2014-03-20 13:12:09.590 Error message from server: SSHServerAPI.SFTP.fxp_attrs")
< 2014-03-20 13:12:09.590 Script: Upload of file 'WC_REPETITIVE_APAC_2013081604183644.dat' was successful, but error occurred while setting the permissions and/or timestamp.
< 2014-03-20 13:12:09.590 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
< 2014-03-20 13:12:09.590 Script: The server does not support the operation.
< 2014-03-20 13:12:09.590 Error code: 8
< 2014-03-20 13:12:09.591 Error message from server: SSHServerAPI.SFTP.fxp_attrs
* 2014-03-20 13:12:09.594 (EScpSkipFile) **Upload of file 'WC_REPETITIVE_APAC_2013081604183644.dat' was successful, but error occurred while setting the permissions and/or timestamp.**
* 2014-03-20 13:12:09.594
* 2014-03-20 13:12:09.595 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
* 2014-03-20 13:12:09.595 The server does not support the operation.
* 2014-03-20 13:12:09.595 Error code: 8
* 2014-03-20 13:12:09.595 Error message from server: SSHServerAPI.SFTP.fxp_attrs
. 2014-03-20 13:12:09.595 Script: Failed
> 2014-03-20 13:12:09.994 Script: exit
. 2014-03-20 13:12:09.994 Script: Exit code: 1
. 2014-03-20 13:12:09.994 Closing connection.
. 2014-03-20 13:12:09.994 Sending special code: 12
. 2014-03-20 13:12:09.994 Sent EOF message
Does that mean that this WinSCP component option is broken? I'm using the latest version of the component - Version=1.1.4.3970.
Thanks,
-Warren.