public static void ExtractAll(string zipFile, string pathTo, bool includeTargetPathing = true) { using (var reader = new Zip.ZipReader(zipFile)) { reader.Entries.ForEach(entry => { entry.ExtractItem(pathTo, includeTargetPathing); }); } }
public static bool UnzipTargetFile(string zipSource, string fileToUnzip, string pathToUnzipTo) { using (var reader = new Zip.ZipReader(zipSource)) { if (!UnzipTargetFile(reader, fileToUnzip, pathToUnzipTo)) { return(false); } } return(true); }
private void UnzipPackageFiles(string zipSource, string pathToUnzipTo) { using (var reader = new Zip.ZipReader(zipSource)) { var deployedItemsPath = pathToUnzipTo + "DeployedItems.xml"; Utilities.UnzipTargetFile(reader, this.manifestFilePath, pathToUnzipTo + "DeployedItems.xml"); //unzip everything in the addeditems folder into a flat list as filenames are unique, but in there db folders UnzipPackageFilesForDB(reader, pathToUnzipTo, "core"); UnzipPackageFilesForDB(reader, pathToUnzipTo, "master"); UnzipPackageFilesForDB(reader, pathToUnzipTo, "web"); } }
public static bool UnzipTargetFile(Zip.ZipReader reader, string fileToUnzip, string filePathToUnzipTo) { var targetFile = reader.Entries.FirstOrDefault(entry => entry.Name == fileToUnzip); if (targetFile == null) { return(false); } string pathToUnzipTo = Path.GetDirectoryName(filePathToUnzipTo); string fileName = Path.GetFileName(filePathToUnzipTo); targetFile.ExtractItem(pathToUnzipTo, false, fileName); return(true); }
private void UnzipPackageFilesForDB(Zip.ZipReader reader, string pathToUnzipTo, string dbName) { var entries = reader.Entries.Where(entry => entry.Name.StartsWith("addeditems/" + dbName)); if (!entries.Any()) { return; } pathToUnzipTo += dbName; System.IO.Directory.CreateDirectory(pathToUnzipTo); pathToUnzipTo += "\\"; entries.ForEach(entry => { if (!entry.IsDirectory) { entry.ExtractItem(pathToUnzipTo, false); } }); }