private static void Call(string arguments) { if (!Archive2.ValidatePath()) { throw new Archive2Exception("Path to Archive2.exe not specified or Archive2.exe not found."); } using (Process proc = new Process()) { LogFile.WriteTimeStamp(); LogFile.WriteLine($">> Archive2.exe {arguments}"); proc.StartInfo.UseShellExecute = false; // = true proc.StartInfo.RedirectStandardOutput = true; // // ... proc.StartInfo.RedirectStandardError = true; // // ... proc.StartInfo.FileName = Archive2.archive2Path; proc.StartInfo.Arguments = arguments; proc.StartInfo.CreateNoWindow = true; // // ... proc.Start(); //MessageBox.Show(/*proc.StandardOutput.ReadToEnd(), */$"Archive2.exe {arguments}"); /*logFile.WriteLine(proc.StandardOutput.ReadToEnd()); * logFile.WriteLine(proc.StandardError.ReadToEnd());*/ string output = proc.StandardOutput.ReadToEnd() + "\n" + proc.StandardError.ReadToEnd(); LogFile.WriteLine(output); proc.WaitForExit(); // System.IO.FileNotFoundException: Could not load file or assembly 'Archive2Interop.dll' if (output.Contains("System.IO.FileNotFoundException:") && output.Contains("'Archive2Interop.dll'")) { throw new Archive2RequirementsException("System.IO.FileNotFoundException: Could not load file or assembly 'Archive2Interop.dll'. 'Visual C++ Redistributable for Visual Studio 2012 Update 4' is likely not installed."); } } }
public static void Extract(string ba2Archive, string outputFolder) { Archive2.Call($"\"{ba2Archive}\" -extract=\"{outputFolder}\" -quiet"); if (!Directory.Exists(outputFolder)) { throw new Archive2Exception("Extraction failed, folder has not been created."); } else if (Utils.IsDirectoryEmpty(outputFolder)) { throw new Archive2Exception("Extraction failed, folder is empty."); } }
private static void CallParallel(string arguments) { if (!Archive2.ValidatePath()) { throw new Archive2Exception("Path to Archive2.exe not specified or Archive2.exe not found."); } using (Process proc = new Process()) { proc.StartInfo.UseShellExecute = false; proc.StartInfo.FileName = Archive2.archive2Path; proc.StartInfo.Arguments = arguments; proc.StartInfo.CreateNoWindow = true; proc.Start(); } }
public static void Create(string ba2Archive, string folder, Archive2.Compression compression, Archive2.Format format) { if (!Directory.Exists(folder) || Utils.IsDirectoryEmpty(folder)) { throw new DirectoryNotFoundException($"The specified folder \"{folder}\" does not exist or is empty."); } string compressionStr = Enum.GetName(typeof(Archive2.Compression), (int)compression); string formatStr = Enum.GetName(typeof(Archive2.Format), (int)format); folder = Path.GetFullPath(folder); Archive2.Call($"\"{folder}\" -create=\"{ba2Archive}\" -compression={compressionStr} -format={formatStr} -root=\"{folder}\" -tempFiles -quiet"); if (!File.Exists(ba2Archive)) { throw new Archive2Exception("Packing failed, archive has not been created."); } }
public static void Create(string ba2Archive, string folder, Archive2.Preset preset) { Archive2.Create(ba2Archive, folder, preset.compression, preset.format); }
public static void Create(string ba2Archive, string folder) { Archive2.Create(ba2Archive, folder, Archive2.Compression.Default, Archive2.Format.General); }
public static void Explore() { Archive2.CallParallel(""); }
public static void Explore(string ba2Archive) { Archive2.CallParallel($"\"{ba2Archive}\""); }