C#中使用7Z进行压缩解压

SevenZipSharp相关文档下载地址:
http://sevenzipsharp.codeplex.com/releases/view/51254

1. 解决方案中添加引用:SevenZipSharp.dll
2. 复制粘贴两个dll文件:7z.dll 7z64.dll,并将属性“复制到输出目录”修改为“如果较
新则复制”

 

  //测试压缩
            var zip = new SevenZipCompressor();
            zip.CompressionLevel=CompressionLevel.High;
            zip.CompressDirectory(@"c:\doc", @"c:\arch.7z");

            //测试解压
            using (var tmp = new SevenZipExtractor(@"c:\arch.7z"))
            {
                for (var i = 0; i < tmp.ArchiveFileData.Count; i++)
                {
                    tmp.ExtractFiles(@"C:\cygwin\", tmp.ArchiveFileData[i].Index);
                }
            }

 

posted @ 2016-01-21 07:57  糖豆爸爸  阅读(5973)  评论(0编辑  收藏  举报
Live2D