private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) { if (e.Cancelled || e.Error != null) { DownloaderCompleted?.Invoke(sender, new DownloaderCompletedEventArgs(e.Cancelled, e.Error)); } else { var index = (int)e.UserState; SWFile swFile = SWFileManager.GetElementAt(index); if (swFile is ArchivedSWFile archivedSWFile) { archivedSWFile.Data = e.Result; } else { string swFilePath = Path.Combine(Language.Path, swFile.Path, Path.GetFileName(swFile.PathD)); string swFileDirectory = Path.GetDirectoryName(swFilePath); Directory.CreateDirectory(swFileDirectory); File.WriteAllBytes(swFilePath, e.Result); } if (SWFileManager.Count > ++index) { DownloadNext(index); } else { DownloaderCompleted?.Invoke(sender, new DownloaderCompletedEventArgs(Language, e.Cancelled, e.Error)); } } }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled || e.Error != null) { DownloaderCompleted?.Invoke(sender, new DownloaderCompletedEventArgs(e.Cancelled, e.Error)); } else { DownloadNext(0); } }