天天看点

.NET中zip的压缩和解压——SharpCompress

     SharpCompress支持的格式:

Archive Format

Compression Format(s)

Compress/Decompress

Archive API

Reader API

Writer API

Rar

Decompress(1)

RarArchive

RarReader

N/A

Zip(2)

None, DEFLATE, BZip2, LZMA/LZMA2, PPMd

Both

ZipArchive

ZipReader

ZipWriter

Tar

None, BZip2, GZip

TarArchive

TarReader

TarWriter(3)

GZip (single file)

GZip

GZipArchive

GZipReader

GZipWriter

7Zip(4)

LZMA, LZMA2, BZip2, PPMd, BCJ, BCJ2

Decompress

SevenZipArchive

(1) SOLID Rars are only supported in the RarReader API. 

(2) Zip format supports pkware and WinzipAES encryption. However, encrypted LZMA is not supported. 

(3) The Tar format requires a file size in the header. If no size is specified to the TarWriter and the stream is not seekable, then an exception will be thrown. 

(4) The 7Zip format doesn't allow for reading as a forward-only stream so 7Zip is only supported through the Archive API。

    也支持流方式的压缩和解压:

Compressor

BZip2Stream

GZipStream

DeflateStream

LZMAStream

PPMdStream

      使用也比较简单:

显示行号 复制代码 ?解压Rar文件

显示行号 复制代码 ?解压zip文件

显示行号 复制代码 ?压缩成zip文件

显示行号 复制代码 ?创建Tar文件

继续阅读