private async Task PatchFileDeprecated(EmbeddedFileAccessor file, IEnumerable <ZipArchiveEntry> prebuiltFiles) { using (System.IO.StreamWriter logFile = new System.IO.StreamWriter(logFilePath, true)) { logFile.WriteLine("Beginning work on file: " + file.name); } string fileName = Path.Combine(txtOutputPath.Text, file.name); DirectoryGuard.CheckDirectory(fileName); var prebuiltFile = prebuiltFiles.SingleOrDefault(fileEntry => String.Equals(fileEntry.FullName.Substring(prebuiltFiles.First().FullName.IndexOf("PSP_GAME")), file.name.Replace("\\", "/"), StringComparison.OrdinalIgnoreCase)); if (prebuiltFile == null) { FileStream fs = new FileStream(fileName, FileMode.Create); file.dataStream.CopyTo(fs); fs.Close(); } else { prebuiltFile.ExtractToFile(fileName); } using (System.IO.StreamWriter logFile = new System.IO.StreamWriter(logFilePath, true)) { logFile.WriteLine("Completed work on file: " + file.name); } this.filesProcessed++; //Update Progress Bar PatchProgressBar.Value = (int)((this.filesProcessed / this.totalFiles) * 100); }
private IEnumerable <EmbeddedFileAccessor> EnumerateFiles() { foreach (string file in fileList) { var newFileAccessor = new EmbeddedFileAccessor(); newFileAccessor.name = file; try { newFileAccessor.dataStream = isoReader.OpenFile(file, FileMode.Open); } catch (Exception e) { string errorMessage = string.Format("There was an error when attempting to open file {0} in the ISO.\r\n\r\n{1}", file, e.Message); MessageBox.Show(errorMessage); Environment.Exit(1); } yield return(newFileAccessor); newFileAccessor.dataStream.Close(); } }
private IEnumerable <EmbeddedFileAccessor> EnumerateFiles() { foreach (string file in fileList) { var newFileAccessor = new EmbeddedFileAccessor(); newFileAccessor.name = file; string filePath = Path.Combine(rootDirectory, file); try { newFileAccessor.dataStream = new FileStream(filePath, FileMode.Open); } catch (Exception e) { string errorMessage = string.Format("There was an error when attempting to open file {0}.\r\n\r\n{1}", file, e.Message); MessageBox.Show(errorMessage); Environment.Exit(1); } yield return(newFileAccessor); newFileAccessor.dataStream.Close(); } }