Selective/Prioritised Downloading

Example 1 Shows how to prevent certain files from being downloaded and also prioritise other files

Example 1

 1         public void SelectiveDownload (TorrentManager manager)
 2         {
 3             Torrent torrent = manager.Torrent;
 4 
 5             // Don't download any files in the 'Docs' subfolder
 6             foreach (TorrentFile file in torrent.Files) {
 7                 if (file.Path.StartsWith ("Docs"))
 8                     file.Priority = Priority.DoNotDownload;
 9             }
10 
11             // Prioritise everything in the 'Data' subfolder
12             foreach (TorrentFile file in torrent.Files) {
13                 if (file.Path.StartsWith ("Data"))
14                     file.Priority = Priority.High;
15             }
16 
17             // Get all '.txt' files first
18             foreach (TorrentFile file in torrent.Files) {
19                 if (file.Path.EndsWith (".txt"))
20                     file.Priority = Priority.Immediate;
21             }
22         }