Differences
This shows you the differences between the selected revisions of the page.
| 2020-08-21 | 2021-03-25 | ||
| empty line between headers improves formatting (martin) | reducing nesting (martin) | ||
| Line 56: | Line 56: | ||
| Task task = new Task(() => | Task task = new Task(() => | ||
| + | { | ||
| + | using (Session downloadSession = new Session()) | ||
| { | { | ||
| - | using (Session downloadSession = new Session()) | + | Console.WriteLine("Starting download {0}...", no); |
| - | { | + | ···························downloadSession.Open(sessionOptions); |
| - | ································Console.WriteLine("Starting download {0}...", no); | + | |
| - | ·······························downloadSession.Open(sessionOptions); | + | |
| - | ································while (true) | + | ····························while (true) |
| + | { | ||
| + | string remoteFilePath; | ||
| + | lock (filesEnumerator) | ||
| { | { | ||
| - | string remoteFilePath; | + | if (!filesEnumerator.MoveNext()) |
| - | ····································lock (filesEnumerator) | + | |
| { | { | ||
| - | if (!filesEnumerator.MoveNext()) | + | break; |
| - | { | + | |
| - | ············································break; | + | |
| - | } | + | |
| - | + | ||
| - | RemoteFileInfo file = filesEnumerator.Current; | + | |
| - | bytes += file.Length; | + | |
| - | count++; | + | |
| - | remoteFilePath = file.FullName; | + | |
| } | } | ||
| - | string localFilePath = | + | RemoteFileInfo file = filesEnumerator.Current; |
| - | RemotePath.TranslateRemotePathToLocal( | + | bytes += file.Length; |
| - | remoteFilePath, remotePath, localPath); | + | count++; |
| - | Console.WriteLine( | + | remoteFilePath = file.FullName; |
| - | ·······································"Downloading {0} to {1} in {2}...", | + | |
| - | remoteFilePath, localFilePath, no); | + | |
| - | Directory.CreateDirectory( | + | |
| - | Path.GetDirectoryName(localFilePath)); | + | |
| - | downloadSession.GetFiles( | + | |
| - | RemotePath.EscapeFileMask(remoteFilePath), | + | |
| - | localFilePath).Check(); | + | |
| } | } | ||
| - | Console.WriteLine("Download {0} done", no); | + | string localFilePath = |
| + | RemotePath.TranslateRemotePathToLocal( | ||
| + | remoteFilePath, remotePath, localPath); | ||
| + | ································Console.WriteLine( | ||
| + | ····································"Downloading {0} to {1} in {2}...", | ||
| + | remoteFilePath, localFilePath, no); | ||
| + | Directory.CreateDirectory( | ||
| + | Path.GetDirectoryName(localFilePath)); | ||
| + | downloadSession.GetFiles( | ||
| + | RemotePath.EscapeFileMask(remoteFilePath), | ||
| + | localFilePath).Check(); | ||
| } | } | ||
| - | ························}); | + | Console.WriteLine("Download {0} done", no); |
| + | } | ||
| + | |||
| + | ····················}); | ||
| tasks.Add(task); | tasks.Add(task); | ||