/// <summary> /// Adds a directory to the archive, compressing it in the process. /// </summary> /// <param name="dir">The directory to compress.</param> /// <param name="workingdir">The working directory to set.</param> /// <param name="level">The amount of compression to use.</param> public void CompressDirectory(string dir, string workingdir, CompressionLevel level = CompressionLevel.Normal) { ArgumentBuilder argumentBuilder = GetCompressionArguments(level); // Adding password switch only if password has been given in constructor if (!string.IsNullOrEmpty(password)) { argumentBuilder.AddSwitch(new SwitchPassword(password)); if (encryptHeaders) { argumentBuilder.Add(new SwitchEncryptHeaders()); } } argumentBuilder.AddTarget(dir); WProcess p = new WProcess(argumentBuilder); if (workingdir != null) { p.BaseProcess.StartInfo.WorkingDirectory = workingdir; } p.ProgressUpdated += ProgressUpdated; p.Execute(); }
/// <summary> /// Extracts everything in the archive to the specified destination. /// </summary> /// <param name="destination">The directory to extract archive contents to.</param> /// <param name="wildcard">The wildcard(s) to extract.</param> /// <param name="overwrite">Whether or not to overwrite existing files. Default false.</param> /// <param name="keepStructure">Whether or not to retain folder structure in the archive. Default true.</param> public void ExtractWildcard(string destination, string wildcard, bool overwrite = false, bool keepStructure = true) { ArgumentBuilder argumentBuilder = GetExtractArguments(destination, overwrite, keepStructure); if (!string.IsNullOrEmpty(password)) { argumentBuilder.AddSwitch(new SwitchPassword(password)); } argumentBuilder.AddTarget(wildcard); WProcess p = new WProcess(argumentBuilder); p.ProgressUpdated += ProgressUpdated; p.Execute(); }