private void writeStreamClosed(WriteStream writeStream) { zipFile.Dispose(); try { using (var ionicZip = new Ionic.Zip.ZipFile(resourceLocation)) { ionicZip.UpdateEntry(writeStream.FileName, writeStream.BaseStream); ionicZip.Save(); } --openWriteStreams; if (openWriteStreams == 0) { if (Directory.Exists(tempFolder)) { Directory.Delete(tempFolder, true); } } else { File.Delete(writeStream.TempFileName); } } finally { zipFile = new ZipFile(resourceLocation); } }
public void copyFile(string from, string to) { zipFile.Dispose(); try { using (Ionic.Zip.ZipFile ionicZip = new Ionic.Zip.ZipFile(resourceLocation)) { var entry = ionicZip[from]; if (entry != null && !entry.IsDirectory) { ionicZip.UpdateEntry(to, (name, stream) => entry.Extract(stream)); ionicZip.Save(); } } } finally { zipFile = new ZipFile(resourceLocation); } }
public void copyDirectory(string from, string to) { zipFile.Dispose(); List <String> files = listFiles("*", from, true).ToList(); //ToList is important here, we need a copy of the list of files or the fail fast iterator will fail when we update try { using (Ionic.Zip.ZipFile ionicZip = new Ionic.Zip.ZipFile(resourceLocation)) { foreach (String fileName in files) { var entry = ionicZip[fileName]; String toPath = Path.Combine(to, Path.GetFileName(entry.FileName)); ionicZip.UpdateEntry(toPath, (name, stream) => entry.Extract(stream)); } ionicZip.Save(); } } finally { zipFile = new ZipFile(resourceLocation); } }