public void CompressionTypeTest()
        {
            File.Delete("test.zip");
            using (var zf = new ZipFile("test.zip"))
            {
                zf.Add(new MemoryStream(new byte[0]), "ZeroBytes", CompressionType.Deflate);
                zf.Add(new MemoryStream(Encoding.ASCII.GetBytes("test")), "Test", CompressionType.Deflate);
                var test = "test";
                for (int i = 0; i < 1000; i++) test += "test";
                zf.Add(new MemoryStream(Encoding.ASCII.GetBytes(test)), "LargeTest", CompressionType.Deflate);
            }
            using (var zf = new ZipFile("test.zip"))
            {
                var zipEntry = zf.Entries.ToArray()[0];
                Assert.AreEqual(zipEntry.CompressionMethod, (ushort)CompressionType.Store);
                Assert.AreEqual((int)zipEntry.CompressedSize, 0);
                Assert.AreEqual((int)zipEntry.UncompressedSize, 0);

                for (int n = 1; n < 3; n++)
                {
                    zipEntry = zf.Entries.ToArray()[n];
                    if (zipEntry.CompressedSize == zipEntry.UncompressedSize)
                    {
                        Assert.AreEqual(zipEntry.CompressionMethod, (ushort) CompressionType.Store);
                    }
                    else
                    {
                        Assert.AreEqual(zipEntry.CompressionMethod, (ushort) CompressionType.Deflate);
                    }
                }
            }
        }
 internal override void MergeZipFile(ZipFile archive, bool overwrite)
 {
     var manifest = overwrite ? _entries.FirstOrDefault(x => x.Name.Equals("AndroidManifest.xml", StringComparison.OrdinalIgnoreCase)) : null;
     base.MergeZipFile(archive, overwrite);
     if (manifest != null)
     {
         _entries.RemoveAll(x => x.Name.Equals("AndroidManifest.xml", StringComparison.OrdinalIgnoreCase));
         _entries.Add(manifest);
     }
 }
 public static string ExtractToTempDir(string archive, string entryName)
 {
     string tempFolder = FolderUtility.CreateTempFolder();
     string path = Path.Combine(tempFolder, Path.GetFileName(entryName));
     using (var zf = new ZipFile(archive))
     {
         ZipEntry ze = zf.Find(entryName);
         if (ze == null) return null;
         zf.Extract(ze, path, true);
     }
     return path;
 }
 public void CloseZipFile()
 {
     if (_zipFile == null) return;
     _zipFile.Close();
     _zipFile = null;
 }
 public UpdateZipHandler(SolutionProperties properties)
 {
     _zipFileName = Path.Combine(properties.OutputUpdateZip);
     FileUtility.DeleteFile(_zipFileName);
     _zipFile = new ZipFile(_zipFileName);
 }
 internal virtual void MergeZipFile(ZipFile archive, bool overwrite)
 {
     if (overwrite)
     {
         _entries.RemoveAll(x => archive.Entries.FirstOrDefault(y => y.Name.Equals(x.Name, StringComparison.OrdinalIgnoreCase)) != null);
         _entries.AddRange(archive.Entries);
         _isDirty = archive._entries.Count != 0;
     }
     else
     {
         var zipEntries = archive.Entries.Where(x => _entries.FirstOrDefault(y => y.Name.Equals(x.Name, StringComparison.OrdinalIgnoreCase)) == null).ToArray();
         _isDirty = zipEntries.Length != 0;
         _entries.AddRange(zipEntries);
     }
 }
 public void MergeZipFile(string file, bool overwrite)
 {
     if (_readOnly) throw new Exception("ZipFile is readonly, merge can not be executed");
     if (_mergeArchives.FirstOrDefault(x => x._archiveFile.Equals(file, StringComparison.OrdinalIgnoreCase)) != null) return;
     var zf = new ZipFile(file, true);
     _mergeArchives.Add(zf);
     MergeZipFile(zf, overwrite);
 }
 public static void ExtractAll(string archive, string folder, bool overwrite)
 {
     using (var zf = new ZipFile(archive, true))
     {
         zf.ExtractAll(folder, overwrite);
     }
 }
 public static bool Contains(string archive, string entryName)
 {
     using (var zf = new ZipFile(archive, true))
     {
         return (zf.Find(ZipEntry.NormalizeName(entryName)) != null);
     }
 }