private void btn_Start_Click(object sender, EventArgs e) { try { // Get settings and check folders FolderIn = TB_Input.Text; FolderOut = TB_Output.Text; bool Recursive = CB_Recursive.Checked; if (!Directory.Exists(FolderIn)) { MessageBox.Show("The input folder is invalid or does not exist.", "Invalid Folder", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Directory.Exists(TB_Output.Text)) { MessageBox.Show("The output folder is invalid or does not exist.", "Invalid Folder", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // Search for save files SaveList = null; if (!SAVUtil.getSavesFromFolder(FolderIn, CB_Recursive.Checked, out SaveList)) { MessageBox.Show("A error has ocurred:\r\n\r\n" + SaveList.First(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (SaveList == null) { MessageBox.Show("The input folder doesn't seem to have any save files.", "No save files", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } totalsaves = SaveList.Count(); progressBar1.Value = 0; DisableControls(); SaveSettings(); if (Worker.IsBusy != true) { Worker.RunWorkerAsync(); } } catch (Exception ex) { MessageBox.Show("A error has ocurred:\r\n\r\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { try { // Process all save files currentsave = 0; invalidSaves = new List <string> { }; validSaves = new List <string> { }; foreach (var file in SaveList) { if (Worker.CancellationPending) { break; } string result; string finalpath; SaveFile SAV = SaveUtil.getVariantSAV(File.ReadAllBytes(file)); if (SAV == null) { invalidSaves.Add(file); currentsave++; Worker.ReportProgress(currentsave * 100 / totalsaves); continue; } validSaves.Add(file); if (CB_File.Checked) { finalpath = getFolderName(FolderOut, SAV); } else { finalpath = FolderOut; } Directory.CreateDirectory(finalpath); // Make sure out directory exists SAVUtil.dumpBoxes(SAV, finalpath, out result, CB_Box.Checked); currentsave++; Worker.ReportProgress(currentsave * 100 / totalsaves); } } catch (Exception ex) { MessageBox.Show("A error has ocurred:\r\n\r\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }