How to compress a directory with the built in .net compression classes?

前端 未结 6 816
囚心锁ツ
囚心锁ツ 2021-01-15 19:15

Using the System.IO.Compression namespaces classes GZIPStream and DeflateStream I successfully can compress and decompress individual files. However, if I pass a directoryna

6条回答
  •  有刺的猬
    2021-01-15 19:30

    When you use GZipStream etc, you are compressing a stream; not a file. GZip has no file header information, so there is no sensible way of packing multiple files. For that you need something like .zip; #ziplib will do the job, but you still (IIRC) need to feed it each file manually.

提交回复
热议问题