private void WriteFolder(ZipOutputStream zipStream, string path, PackageFolder folder) { foreach (PackageEntry packageEntry in (IEnumerable <PackageEntry>)folder.GetEntries()) { if (packageEntry is PackageFile) { zipStream.PutNextEntry(new ZipEntry(this.CombinePath(path, packageEntry.Name))); byte[] data = ((PackageFile)packageEntry).Data; ((Stream)zipStream).Write(data, 0, data.Length); zipStream.CloseEntry(); } if (packageEntry is PackageFolder) { this.WriteFolder(zipStream, this.CombinePath(path, packageEntry.Name), (PackageFolder)packageEntry); } } }
private void Write(DirectoryInfo directory, PackageFolder folder) { foreach (PackageEntry entry in folder.GetEntries()) { if (!this.FilterEntry(entry)) { if (entry is PackageFolder) { this.Write(directory.CreateSubdirectory(entry.Name), (PackageFolder)entry); } if (entry is PackageFile) { File.WriteAllBytes(Path.Combine(directory.FullName, entry.Name), ((PackageFile)entry).Data); } } } }