private void DoDownloadAndSaveAllFiles(List<FileData> filesToDownload, List<FileData> successfullyDownloadedFiles)
{
bool cancelled = false;
foreach (var fileData in filesToDownload)
{
if (cancelled)
{
break;
}
_currentFile = fileData;
var url = new Uri(fileData.ServerFile);
var request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
response.Close();
}
catch (WebException e)
{
MessageBox.Show("Could not download the file at\n" + url);
continue;
}
DoDownloadAndSaveFile(ref cancelled, fileData, url, response);
if (updateWorkerThread.CancellationPending)
{
return;
}
else
{
successfullyDownloadedFiles.Add(fileData);
}
}
}