C#使用SevenZipSharp库时如何去掉压缩文件中的目录文件夹
2016-06-02 22:20
387 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { try { //注意区分项目是32位还是64位调用相应位的7z.dll. SevenZip.SevenZipCompressor.SetLibraryPath("7z.dll"); SevenZip.SevenZipCompressor MyCompressor = new SevenZip.SevenZipCompressor(); //默认设置 MyCompressor.ArchiveFormat = SevenZip.OutArchiveFormat.SevenZip; MyCompressor.CompressionMethod = SevenZip.CompressionMethod.Lzma; MyCompressor.CompressionMode = SevenZip.CompressionMode.Create; MyCompressor.ZipEncryptionMethod = SevenZip.ZipEncryptionMethod.Aes256; //普通压缩压缩的文件带有文件夹,有时候使用不太方便 //MyCompressor.CompressFiles(@"data\text\1.txt.7z", @"data\text\1.txt"); //使用字典压缩,自定义格式 Dictionary<string, string> MyDic = new Dictionary<string, string>(); //key为压缩包中的文件名 //value为待压缩文件 MyDic["1.txt"] = @"data\text\1.txt"; MyCompressor.CompressFileDictionary(MyDic, @"data\text\1.txt.7z");//注意第二个参数为输出压缩包的文件 } catch (Exception e) { Console.WriteLine(e.Message); } } } }
相关文章推荐
- c#调用COM组件
- 如何在 Ubuntu Linux 中使用 RAR 文件
- C#实现把指定数据写入串口
- C#动态创建button的方法
- C#中抽象方法与虚拟方法的区别
- c#中虚函数的相关使用方法
- C#实现给图片加水印的方法
- C#使用加边法计算行列式的值
- C#实现多线程的同步方法实例分析
- C#中尾递归的使用、优化及编译器优化
- C#中的delegate委托类型基本学习教程
- C#实现子窗体与父窗体通信方法实例总结
- C#通用邮件发送类分享
- 举例讲解C#中自动实现的属性
- C#中this的用法集锦
- C#数据结构之顺序表(SeqList)实例详解
- C#.NET获取拨号连接的宽带连接方法
- C#异步绑定数据实现方法
- C#实现AddRange为数组添加多个元素的方法
- C#中Equality和Identity浅析