コード例 #1
0
 protected override void StartNextDownload()
 {
     try
     {
         Directory.CreateDirectory(DownloadsController.CurrentDownload.Destination.FullPath);
         //Http is way more simple than FTP, since it has a built in background worker, no authentication and no folders
         using (client = new CustomWebClient())
         {
             speed = new DownloadSpeed(client);
             speed.Start();
             client.Credentials              = Credentials;
             client.DownloadProgressChanged += CustomWebClientDownloadProgressChanged;
             client.DownloadFileCompleted   += CustomWebClientDownloadCompleted;
             OnDownloadStarted();
             //downloads the file and save in the selected destination
             client.DownloadFileAsync(new Uri(DownloadsController.CurrentDownload.RemoteFileInfo.Url), UpdateFileNameWithDistinguishedName());
         }
     }
     catch (Exception e)
     {
         DownloadsController.CurrentDownload.ChangeState(DownloadState.Error, true);
         OnProcessError(new DownloadErrorEventArgs(ErrorType.GeneralErrorOnDownload, DownloadsController.CurrentDownload.RemoteFileInfo.FileFullName, e));
     }
     finally
     {
         //the progress of the download list has changed
         OnOverallProgressChanged();
     }
 }