Differences
This shows you the differences between the selected revisions of the page.
2013-04-15 | 2013-04-26 | ||
&beta_feature (martin) | Converting to .NET Assembly (martin) | ||
Line 36: | Line 36: | ||
</code> | </code> | ||
+ | ===== Converting to .NET Assembly ===== | ||
+ | When [[library_from_script|converting script to .NET Assembly]], map ''get'' command to ''[[library_session_getfiles|Session.GetFiles]]'' method. | ||
+ | Parameters mapping: Command parameter ''file'' maps to method parameter ''remotePath''. When multiple source file parameters are used, you need to call ''Session.GetFiles'' multiple times. Command parameter ''directory\newname'' maps to method parameter ''localPath''. You have to [[library_from_script#paths|convert relative paths to absolute paths]]. | ||
+ | |||
+ | Switches mapping: | ||
+ | ^ Switch ^ Mapping ^ | ||
+ | | ''-delete'' | Value ''true'' (''$TRUE'') for method parameter ''remove''. | | ||
+ | | ''-resume'' | Not supported. | | ||
+ | | ''-append'' | Not supported. | | ||
+ | | ''-preservetime'' \\ ''-nopreservetime'' \\ ''-transfer'' \\ ''-filemask'' \\ ''-resumesupport'' | [[library_from_script_transfer_settings|Converting transfer settings scripting switches]] to .NET assembly class ''TransferSettings''. | | ||
+ | | ''-speed=<kibps>'' | Not supported. | | ||
+ | |||
+ | To emulate ''[[scriptcommand_option|option batch abort]]'' mode, call ''[[library_operationresultbase|TransferOperationResult.Check]]'' on method's result. See also [[library_session#results|Capturing results of operations]]. | ||
+ | |||
+ | For example, following script snippet | ||
+ | <code winscp> | ||
+ | option batch abort | ||
+ | ... | ||
+ | cd /home/martinp | ||
+ | lcd d:\ | ||
+ | ... | ||
+ | get -delete -filemask=*>1M -resumesupport=off *.txt *.xml web\ | ||
+ | </code> | ||
+ | maps to following PowerShell code | ||
+ | <code powershell> | ||
+ | $transferOptions = New-Object WinSCP.TransferOptions | ||
+ | # -filemask=*>1M | ||
+ | $transferOptions.FileMask = "*>1M" | ||
+ | # -resumesupport=off | ||
+ | $resumeSupport = New-Object TransferResumeSupport | ||
+ | $resumeSupport.State = [WinSCP.TransferResumeSupportState]::Off | ||
+ | $transferOptions.ResumeSupport = $resumeSupport | ||
+ | # Absolute paths + $TRUE for -delete + Two calls for two source parameters | ||
+ | $transferResult = $session.GetFiles("/home/martinp/*.txt", "d:\web\", $TRUE, $transferOptions) | ||
+ | $transferResult = $session.GetFiles("/home/martinp/*.xml", "d:\web\", $TRUE, $transferOptions) | ||
+ | # Throw on any error to emulate "option batch abort" | ||
+ | $transferResult.Check() | ||
+ | </code> |