private static FileInfo DownloadFileFromURLToPath(string url, string path, WebClient webClient, bool callProgressBar) { progressBar = callProgressBar; if (callProgressBar) { int num = 0; } try { if (webClient == null) { using (webClient = new WebClient()) { webClient.DownloadProgressChanged += webClient_DownloadProgressChanged; webClient.DownloadFileCompleted += webClient_DownloadFileCompleted; webClient.DownloadFileAsync(new Uri(url), path); WebClient webClient2 = webClient; if (!downloadInterrupted) { if (currentUpdateForm != null) { currentUpdateForm.RepeatUntilBusy(webClient); } if (currentMainMenuForm != null) { currentMainMenuForm.RepeatUntilBusy(webClient); } return(new FileInfo(path)); } return(null); } } webClient.DownloadProgressChanged += webClient_DownloadProgressChanged; webClient.DownloadFileCompleted += webClient_DownloadFileCompleted; webClient.DownloadFileAsync(new Uri(url), path); if (!downloadInterrupted) { if (currentUpdateForm != null) { currentUpdateForm.RepeatUntilBusy(webClient); } if (currentMainMenuForm != null) { currentMainMenuForm.RepeatUntilBusy(webClient); } return(new FileInfo(path)); } return(null); } catch (WebException) { currentMainMenuForm.internetIsAbsent = true; return(null); } }
/// <summary> /// Метод для самого процесса скачки /// </summary> /// <param name="zipFilePath"></param> /// <param name="zipFileFolderPath"></param> public static void Download(string zipFilePath, string zipFileFolderPath) { wc = new WebClient(); zipReadingStream = wc.OpenRead(zipFilePath); zip = new ZipArchive(zipReadingStream); zip.ExtractToDirectory(zipFileFolderPath, _progress); flag = BoolConfirmation.checkIfUpdateIsRequired(form2.pathToFile, "https://drive.google.com/file/d/1jDScpEkq-mybtv4SNtL-rjyE-9wM4Uos/view?usp=sharing", form1, form2); form1.flagToContinue = flag; form1.RepeatUntilBusy(wc); disposeHere(); File.Delete(archivePath); form2.updateInProgress = false; form2.archiveBegun = false; string message = ""; long updateBytes = 1L; bool sizeDiffers = false; string[] info = null; Thread.Sleep(1500); flag = BoolConfirmation.checkIfUpdateIsRequired(form2.pathToFile, "https://drive.google.com/file/d/1jDScpEkq-mybtv4SNtL-rjyE-9wM4Uos/view?usp=sharing", ref message, form1, form2, ref updateBytes, ref sizeDiffers, ref info); form1.flagToContinue = true; form1.isModInstalled = true; form2.isModInstalled = true; form2.updateRequired = flag; form1.updateRequired = flag; if (form1.reinstall) { form1.reinstall = false; form1.isModInstalled = true; } if (!flag || patch) { form2.updateInProgress = false; } else { form1.downloadAllPatches(true); } //костыль по смене галочки для скачки фигни //Установка технически переменных, которые были не убраны из метода по обновлению короч этого самого вашего лончера. }