/// <summary> /// Unzips all files in the path. /// </summary> /// <param name="path">The zip files.</param> /// <param name="target">The directory where the files must be unzipped.</param> /// <returns>The uncompressed files and folders.</returns> public static Path Unzip(this Path path, Path target) { path.Open((s, p) => target.ForEach(t => new ZipArchive(s, ZipArchiveMode.Read).ExtractToDirectory(t.FullPath))); return(target); }
/// <summary> /// Unzips all files in the path. /// </summary> /// <param name="path">The zip files.</param> /// <param name="unzipAction">An action that handles the unzipping of each file.</param> /// <returns>The original path object</returns> public static Path Unzip(this Path path, Action <string, byte[]> unzipAction) { path.Open((s, p) => Unzip(s, unzipAction)); return(path); }
/// <summary> /// Zips dynamically created contents. /// </summary> /// <param name="target"> /// The path of the target zip file. /// If target has more than one file, only the first one is used.</param> /// <param name="zipPaths">The zipped paths of the files to zip.</param> /// <param name="zipPathToContent"> /// A function that maps the zipped paths to the binary content of the file to zip. /// </param> /// <returns>The zipped path.</returns> public static Path Zip(this Path target, Path zipPaths, Func <Path, byte[]> zipPathToContent) { target.Open(s => ZipToStream(zipPaths, p => zipPathToContent(p), s), FileMode.Create, FileAccess.ReadWrite, FileShare.None); return(target); }