C# – Create zip style file without compression

c++

I know that there are many free and not so free compression libraries out there, but for the project i am working on, i need to be able to take file data from a stream and put it into some kind zip or pack file, but without compression, because i will need to access these files quickly without having to wait for them to decompress.

Anyone know how this could be approached, or if there are some libraries out there that do this that i am not aware of?

Best Solution

You can use Zip for this. You would use a compression level of something like "none" or "store", which just combines the files without compression. This site enumerates some of them:

  • Maximum - The slowest of the compression options, but the most useful for creating small archives.
  • Normal - The default value.
  • Low - Faster than the default, but less effective.
  • Minimum - Extremely fast compression, but not as efficient as other methods.
  • None - Creates a ZIP file but does not compress it. File size may be slightly larger if archive is encrypted or made self-extracting.

Here are some C# examples:

For the unix unaware, this is exactly what tar does. When you see .tar.gz files, it's just a bunch of files combined into a tar file, and then run through gzip.