SelectivePrioritised Downloading
Version 3 (Alan McGovern, 07/30/2009 01:20 AM)
| 1 | 2 | Alan McGovern | h1. Selective/Prioritised Downloading |
|---|---|---|---|
| 2 | 1 | ||
| 3 | 3 | Alan McGovern | [[Selective/Prioritised Downloading#Example-1|Example 1]] Shows how to prevent certain files from being downloaded and also prioritise other files |
| 4 | 3 | Alan McGovern | |
| 5 | 3 | Alan McGovern | h2. Example 1 |
| 6 | 3 | Alan McGovern | |
| 7 | 1 | <pre><code> |
|
| 8 | 1 | public void SelectiveDownload (TorrentManager manager) |
|
| 9 | 1 | { |
|
| 10 | 1 | Torrent torrent = manager.Torrent; |
|
| 11 | 1 | ||
| 12 | 1 | // Don't download any files in the 'Docs' subfolder |
|
| 13 | 1 | foreach (TorrentFile file in torrent.Files) { |
|
| 14 | 1 | if (file.Path.StartsWith ("Docs")) |
|
| 15 | 1 | file.Priority = Priority.DoNotDownload; |
|
| 16 | 1 | } |
|
| 17 | 1 | ||
| 18 | 1 | // Prioritise everything in the 'Data' subfolder |
|
| 19 | 1 | foreach (TorrentFile file in torrent.Files) { |
|
| 20 | 1 | if (file.Path.StartsWith ("Data")) |
|
| 21 | 1 | file.Priority = Priority.High; |
|
| 22 | 1 | } |
|
| 23 | 1 | ||
| 24 | 1 | // Get all '.txt' files first |
|
| 25 | 1 | foreach (TorrentFile file in torrent.Files) { |
|
| 26 | 1 | if (file.Path.EndsWith (".txt")) |
|
| 27 | 1 | file.Priority = Priority.Immediate; |
|
| 28 | 1 | } |
|
| 29 | 1 | } |
|
| 30 | 1 | </code> |
|
| 31 | 1 | </pre> |