.Net中的7Zip——Sharpcompress

虽然微软在.net 4.5中集成了对zip的解压支持,但还是比较弱。如果我们想让程序像7zip那样支持万能解压,Sharpcompress可以帮你实现这个目标,它是一个C#写的压缩/解压工具,虽然还没能做得像7Zip那么NB,当支持的格式也是相当多的,如下就是目前的支持情况:

Archive Format

Compression Format(s)

Compress/Decompress

Archive API

Reader API

Writer API

Rar

Rar

Decompress(1)

RarArchive

RarReader

N/A

Zip(2)

None, DEFLATE, BZip2, LZMA/LZMA2, PPMd

Both

ZipArchive

ZipReader

ZipWriter

Tar

None, BZip2, GZip

Both

TarArchive

TarReader

TarWriter(3)

GZip (single file)

GZip

Both

GZipArchive

GZipReader

GZipWriter

7Zip(4)

LZMA, LZMA2, BZip2, PPMd, BCJ, BCJ2

Decompress

SevenZipArchive

N/A

N/A

(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

并且这个库是一个portable的,.NET/Mono/Silverlight/WP7等框架都可以用,还等什么,赶紧安装吧:

    PM> Install-Package sharpcompress

并且它也在NUGET上提供了一些范例:

    PM> Install-Package p3-sharpcompress

如果要更详细的了解它,可以参看它的项目主页1:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值