Converting Transfer Settings Scripting Switches to Code Based on .NET Assembly

When converting script to .NET Assembly, map transfer settings switches on file transfer scripting commands (get, put and synchronize) as follows:

Switch Mapping
-resume Set TransferOptions.OverwriteMode to OverwriteMode.Resume (Enumeration syntax in PowerShell is [WinSCP.OverwriteMode]::Resume).
-resume Set TransferOptions.OverwriteMode to OverwriteMode.Append ([WinSCP.OverwriteMode]::Append).
-preservetime This is default.
To set it explicitly, set TransferOptions.PreserveTimestamp to true ($True in PowerShell).
-nopreservetime Set TransferOptions.PreserveTimestamp to false ($False).
-permissions Create new instance of FilePermissions and set FilePermissions.Octal to a value of the switch. Assign instance of FilePermissions to TransferOptions.FilePermissions.
-nopermissions This is default.
To set it explicitly, set TransferOptions.FilePermissions to null ($Null).
-transfer Set TransferOptions.TransferMode. Use TransferMode.Binary for binary, TransferMode.Ascii for ascii and TransferMode.Automatic for automatic.
-filemask Set TransferOptions.FileMask. Value syntax is identical.
-resumesupport Set TransferOptions.ResumeSupport. For on and off set TransferOptions.ResumeSupport.State to TransferResumeSupportState.On and TransferResumeSupportState.Off respectively. When threshold is used, set TransferOptions.ResumeSupport.State to TransferResumeSupportState.Smart and TransferOptions.ResumeSupport.Threshold to the threshold value.
Enumeration syntax in PowerShell is like [WinSCP.TransferResumeSupportState]::On.
-speed Set TransferOptions.SpeedLimit.

Advertisement

Note that not all script commands (and .NET assembly methods respectively) make use of all the switches. Refer to respective command documentation for valid switches.

Last modified: by martin