Differences
This shows you the differences between the selected revisions of the page.
2011-12-28 | 2013-05-07 | ||
lists remote directory (martin) | Converting to .NET Assembly (martin) | ||
Line 15: | Line 15: | ||
ls | ls | ||
</code> | </code> | ||
+ | |||
+ | ===== Converting to .NET Assembly ===== | ||
+ | When [[library_from_script|converting script to .NET Assembly]], map ''ls'' command to ''[[library_session_listdirectory|Session.ListDirectory]]'' method and print returned ''[[library_remotedirectoryinfo|RemoteDirectoryInfo]]'' in your preferred format. | ||
+ | |||
+ | Parameters mapping: Command parameter ''directory/wildcard'' maps to method parameter ''path''. You have to [[library_from_script#paths|convert relative path to absolute path]]. | ||
+ | |||
+ | For example, following script snippet: | ||
+ | |||
+ | <code winscp> | ||
+ | cd /home/martinp | ||
+ | ls | ||
+ | </code> | ||
+ | |||
+ | maps to following PowerShell code: | ||
+ | |||
+ | <code powershell> | ||
+ | $directory = $session.ListDirectory("/home/martinp") | ||
+ | |||
+ | foreach ($fileInfo in $directory.Files) | ||
+ | { | ||
+ | Write-Host ("{0}{1} {2,9} {3,-12:MMM dd HH:mm:ss yyyy} {4}" -f | ||
+ | $fileInfo.FileType, $fileInfo.FilePermissions, $fileInfo.Length, | ||
+ | $fileInfo.LastWriteTime, $fileInfo.Name) | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Note that this omits inode, owner and group as these are not available in .NET assembly. | ||