private void CorruptedFilesFound() { DiscordLauncherPresence.Status("Verify Bad", null); /* START Show Redownloader Progress*/ StartScanner.SafeInvokeAction(() => StartScanner.Visible = false); StopScanner.SafeInvokeAction(() => StopScanner.Visible = true); VerifyHashText.SafeInvokeAction(() => VerifyHashText.Text = "Currently (re)downloading files\nThis part may take awhile\ndepending on your connection."); if (File.Exists("invalidfiles.dat") && File.ReadAllLines("invalidfiles.dat") != null) { DownloadProgressText.SafeInvokeAction(() => DownloadProgressText.Text = "\nPreparing to Download Files"); string[] files = File.ReadAllLines("invalidfiles.dat"); foreach (string text in files) { if (!ForceStopScan) { try { while (StillDownloading) { } if (!ForceStopScan) { currentCount = files.Count(); string text2 = FileSettingsSave.GameInstallation + text; string address = FinalCDNURL + "/unpacked" + text.Replace("\\", "/"); if (File.Exists(text2)) { try { LogVerify.Deleted("File: " + text2); File.Delete(text2); } catch (Exception Error) { LogVerify.Error("File: " + text2 + " Error: " + Error.Message); LogVerify.ErrorIC("File: " + text2 + " Error: " + Error.HResult); LogVerify.ErrorFR("File: " + text2 + " Error: " + Error.ToString()); } } try { if (!new FileInfo(text2).Directory.Exists) { new FileInfo(text2).Directory.Create(); } } catch (Exception Error) { LogToFileAddons.OpenLog("VERIFY HASH File Info", null, Error, null, true); } Uri URLCall = new Uri(address); int Timeout = (int)TimeSpan.FromMinutes(5).TotalMilliseconds; if (address.Contains("copspeechdat")) { Timeout = (int)TimeSpan.FromMinutes(30).TotalMilliseconds; } else if (address.Contains("nfs09mx.mus")) { Timeout = (int)TimeSpan.FromMinutes(15).TotalMilliseconds; } ServicePointManager.FindServicePoint(URLCall).ConnectionLeaseTimeout = Timeout; var Client = new WebClient(); if (!WebCalls.Alternative()) { Client = new WebClientWithTimeout(); } else { Client.Headers.Add("user-agent", "SBRW Launcher " + Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)"); } Client.DownloadProgressChanged += (Systems, RecevingData) => { if (RecevingData.TotalBytesToReceive >= 1 && !ForceStopScan) { DownloadProgressText.SafeInvokeAction(() => DownloadProgressText.Text = "Downloading File [ " + redownloadedCount + " / " + currentCount + " ]:\n" + CurrentDownloadingFile + "\n" + TimeConversions.FormatFileSize(RecevingData.BytesReceived) + " of " + TimeConversions.FormatFileSize(RecevingData.TotalBytesToReceive)); } else if (ForceStopScan) { Client.CancelAsync(); } }; Client.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted); try { Client.DownloadFileAsync(URLCall, text2); CurrentDownloadingFile = text; StillDownloading = true; } catch (Exception Error) { if (!ForceStopScan) { redownloadErrorCount++; } LogToFileAddons.OpenLog("VERIFY HASH", null, Error, null, true); } finally { if (Client != null) { Client.Dispose(); } } } else { break; } } catch (Exception Error) { if (!ForceStopScan) { redownloadErrorCount++; } LogToFileAddons.OpenLog("VERIFY HASH", null, Error, null, true); } finally { if (IsVerifyHashOpen) { Application.DoEvents(); GC.Collect(); } } } else { break; } } } }