如何COM preSS与目录内置的.NET COM pression类?目录、preSS、COM、NET

2023-09-03 04:23:40 作者:给我个怀抱

使用System.IO.Com pression命名空间类GZIPStream和DeflateStream我能够成功地融为一体preSS和DECOM preSS单个文件。但是,如果我通过一个目录名作为目标COM pression我得到一个安全异常。我必须(递归)列举的所有文件和子目录,以便能够融为一体preSS目录?

Using the System.IO.Compression namespaces classes GZIPStream and DeflateStream I successfully can compress and decompress individual files. However, if I pass a directoryname as target for compression I get a security exception. Do I have to (recursively) enumerate all files and subdirectories to be able to compress a directory?

(大概从codePLEX dotnetzip会处理这更好的,但是这不是我现在后)。

(Probably dotnetzip from codeplex will handle this better, but that is not what I am after now).

推荐答案

在使用 GZipStream 等等,你是COM pressing一个流;不是一个文件。 的GZip 没有文件头信息,所以打包多个文件的任何合理的方式。对于您需要类似的.zip; #ziplib将做的工作,但你仍然(IIRC)需要手动喂它的每个文件。

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.