mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Q: ArchiveType vs CompressionType #251
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 @evil-shrike on GitHub (Oct 26, 2017).
Hi!
I can't understand how to choose a format. When I create a stream I use
ArchiveFactory.Create(ArchiveType.Zip)but then I have to choose CompressionType :why? How do ArchiveType and CompressionType relate to each other?
Moreover this code throws SharpCompress.Common.InvalidFormatException: Invalid compression method: GZip.
Zip archive can't have GZip compression type?
I found out that ArchiveType.Zip is compatible with CompressionType.Deflate. But it's weird API.
@adamhathcock commented on GitHub (Oct 26, 2017):
You've got it it seems. Yes, GZip is slightly weird and isn't supported on Zip as detailed here: https://github.com/adamhathcock/sharpcompress/wiki/Supported-Formats
Yes, it is slightly weird because it's trying to be powerful. If you've got suggestions on how to fix the API, then please let me know.
@evil-shrike commented on GitHub (Oct 26, 2017):
Ok, got it.
ArchiveType determines a subset of compression types.
Well, I'd suggest some default
SaveTo:if no
WriterOptionswas specified then the lib will choose some default based on its ArchiveType.@adamhathcock commented on GitHub (Oct 26, 2017):
You can also just put
CompressionTypein directly as it's implicitly converted.@evil-shrike commented on GitHub (Oct 26, 2017):
Ok, that's nice.
But I meant to allow skipping
CompressionTypeat all:zipArchive.SaveTo(stream)@adamhathcock commented on GitHub (Oct 26, 2017):
Yeah that's fine too.
@evil-shrike commented on GitHub (Oct 26, 2017):
but it doesn't work ) there's no such method in
IWritableArchive@adamhathcock commented on GitHub (Oct 26, 2017):
Looks like this https://github.com/adamhathcock/sharpcompress/blob/master/tests/SharpCompress.Test/Zip/ZipArchiveTests.cs#L269