Differences
This shows you the differences between the selected revisions of the page.
| 2017-10-03 | 2017-10-03 | ||
| using variable expansion in strings in powershell (martin) | code wrapping for new design (martin) | ||
| Line 25: | Line 25: | ||
| UserName = "user", | UserName = "user", | ||
| Password = "mypassword", | Password = "mypassword", | ||
| - | SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" | + | SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..." |
| }; | }; | ||
| Line 42: | Line 42: | ||
| Console.WriteLine("Starting files enumeration..."); | Console.WriteLine("Starting files enumeration..."); | ||
| - | IEnumerable<RemoteFileInfo> files = session.EnumerateRemoteFiles(remotePath, null, EnumerationOptions.AllDirectories); | + | IEnumerable<RemoteFileInfo> files = |
| + | ···················session.EnumerateRemoteFiles( | ||
| + | ························remotePath, null, EnumerationOptions.AllDirectories); | ||
| IEnumerator<RemoteFileInfo> filesEnumerator = files.GetEnumerator(); | IEnumerator<RemoteFileInfo> filesEnumerator = files.GetEnumerator(); | ||
| Line 74: | Line 76: | ||
| } | } | ||
| - | string localFilePath = session.TranslateRemotePathToLocal(remoteFilePath, remotePath, localPath); | + | string localFilePath = |
| - | Console.WriteLine("Downloading {0} to {1} in {2}...", remoteFilePath, localFilePath, no); | + | ·······································session.TranslateRemotePathToLocal( |
| - | Directory.CreateDirectory(Path.GetDirectoryName(localFilePath)); | + | ············································remoteFilePath, remotePath, localPath); |
| - | downloadSession.GetFiles(session.EscapeFileMask(remoteFilePath), localFilePath).Check(); | + | Console.WriteLine( |
| + | ········································"Downloading {0} to {1} in {2}...", | ||
| + | ·······································remoteFilePath, localFilePath, no); | ||
| + | Directory.CreateDirectory( | ||
| + | ········································Path.GetDirectoryName(localFilePath)); | ||
| + | downloadSession.GetFiles( | ||
| + | ········································session.EscapeFileMask(remoteFilePath), localFilePath). | ||
| + | ········································Check(); | ||
| } | } | ||
| Line 153: | Line 162: | ||
| $batch = [int]($total / $batches) | $batch = [int]($total / $batches) | ||
| - | Write-Host "Will download $($files.Count) files totaling $total bytes in $batches parallel batches, $batch bytes on average in each" | + | Write-Host ( |
| + | ············"Will download $($files.Count) files totaling $total bytes in " + | ||
| + | "$batches parallel batches, $batch bytes on average in each") | ||
| $start = 0 | $start = 0 | ||
| Line 171: | Line 182: | ||
| # Start the background job for the batch | # Start the background job for the batch | ||
| - | Start-Job -Name "Batch $no" -ArgumentList $dllPath, $sessionUrl, $remotePath, $localPath, $no, $fileList { | + | Start-Job -Name "Batch $no" ` |
| + | ····················-ArgumentList $dllPath, $sessionUrl, $remotePath, $localPath, $no, $fileList { | ||
| param ( | param ( | ||
| [Parameter(Position = 0)] | [Parameter(Position = 0)] | ||
| Line 192: | Line 204: | ||
| # Load WinSCP .NET assembly. | # Load WinSCP .NET assembly. | ||
| - | # Need to use an absolute path as the Job is started from user's documents folder. | + | # Need to use an absolute path as the Job is started |
| + | # from user's documents folder. | ||
| Add-Type -Path $dllPath | Add-Type -Path $dllPath | ||
| Line 215: | Line 228: | ||
| Write-Host "Downloading $remoteFilePath to $localFilePath in $no" | Write-Host "Downloading $remoteFilePath to $localFilePath in $no" | ||
| - | $session.GetFiles($session.EscapeFileMask($remoteFilePath), $localFilePath).Check() | + | $session.GetFiles( |
| + | ····································$session.EscapeFileMask($remoteFilePath), $localFilePath). | ||
| + | ····································Check() | ||
| } | } | ||
| } | } | ||