public void ExtractMod(Form1 form1) { _form1 = form1; if (modIndex < _form1.modList.Count) { if (_form1.modList[modIndex].State_Extracted == false && _form1.modList[modIndex].ActionToTake == "Install" && _form1.modList[modIndex].ArchiveFileName != "") { _form1.ProgressLabelUpdate("Extracting " + _form1.modList[modIndex].ModName + "..."); string fileName = _form1.modList[modIndex].ArchiveFileName; int fileNameLength = fileName.Length; string dirName = fileName.Remove((fileNameLength - 4), 4); string destDir = @".\GPPInstaller\" + dirName; DirectoryInfo destDirInfo = new DirectoryInfo(destDir); string zipFile = @".\GPPInstaller\" + fileName; if (!destDirInfo.Exists) { Directory.CreateDirectory(destDir); if (File.Exists(zipFile)) { // NOTE: It appears that when entering the worker for // a second time (re-use the previous worker) the values // of variables are re-used. // NOTE: The solution to this problem was to pass new arguments to the // background worker DoWork event. Used a Tuple since you can only pass // one arg. var args = new Tuple <string, string>(zipFile, destDir); try { workerExtract.RunWorkerAsync(args); } catch (Exception) { throw new InvalidDataException(); } } } } else { modIndex++; ExtractMod(_form1); } } else { modIndex = 0; GlobalInfo.DeleteAllZips(@".\GPPInstaller"); CopyMod(_form1); } }
public void webclient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Cancelled) { GlobalInfo.DeleteAllZips(@".\GPPInstaller"); _form1.InstallCanceled(); _form1.EndOfInstall(); return; } _form1.ProgressBar1Step(); modIndex++; DownloadMod(_form1); }