mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-08 21:21:57 +00:00
Build archive in memorystream while keeping it open #130
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @zaryk on GitHub (Sep 27, 2016).
Is there a way to build archive in memorystream while keeping it open? The below way seems to create it, but once returned, it is not open. I also looked at the ZipArchive constructor where there is an option to keep it open, but passing in the stream said that it could not find zip headers. I just need a regular zip. I know the supported formats for streams are the below, so does that mean this will not work?
BZip2Stream Both
GZipStream Both
DeflateStream Both
LZMAStream Both
PPMdStream Both
internal virtual MemoryStream InternalDownloadStream(int offset, int readSize) { var archive = ZipArchive.Create(); archive.AddAllFromDirectory(directoryInfo.FullName, "*.*", SearchOption.AllDirectories); var stream = new MemoryStream(); if (offset == 0 && readSize == 0) { archive.SaveTo(stream, new CompressionInfo() { DeflateCompressionLevel = Core.SharpCompress.Compressor.Deflate.CompressionLevel.Default, Type = CompressionType.None }); return stream; } else { throw new NotImplementedException(); } }