四联光电智能照明论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2818|回复: 0
打印 上一主题 下一主题

.Net中的7Zip——Sharpcompress

[复制链接]
  • TA的每日心情
    开心
    2018-12-28 16:25
  • 817

    主题

    1556

    帖子

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    14941
    跳转到指定楼层
    楼主
    发表于 2016-10-30 09:40:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    虽然微软在.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:
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|Silian Lighting+ ( 蜀ICP备14004521号-1 )

    GMT+8, 2024-5-5 08:26 , Processed in 1.078125 second(s), 26 queries .

    Powered by Discuz! X3.2

    © 2001-2013 Comsenz Inc.

    快速回复 返回顶部 返回列表