Usage of Seven Zip in C#
Compresss by Squid-Box.SevenZipSharp.Lite
choose x86/x64 7z dll
if (IntPtr.Size == 4)
{
SevenZipExtractor.SetLibraryPath(@"x86\7z.dll");
}
else
{
SevenZipExtractor.SetLibraryPath(@"x64\7z.dll");
}
if (IntPtr.Size == 4)
{
SevenZipCompressor.SetLibraryPath(@"x86\7z.dll");
}
else
{
SevenZipCompressor.SetLibraryPath(@"x64\7z.dll");
}
Decompression As File
using (SevenZipExtractor tmp = new SevenZipExtractor("Name.7z")))
{
for (int i = 0; i < tmp.ArchiveFileData.Count; i++)
{
tmp.ExtractFiles("Path to sotre decompression file", tmp.ArchiveFileData[i].Index);
}
}
Compress to memoryStream
SevenZipCompressor ziper = new SevenZipCompressor()
{
ArchiveFormat = OutArchiveFormat.SevenZip,
DirectoryStructure = false
};
using (MemoryStream zippedStream = new MemoryStream())
{
ziper.DefaultItemName = "DefaultItemName ";
ziper.CompressStream(InputOrginalStream, ZipedOutStream);
using (FileStream fs = new FileStream("Path to store", FileMode.Create))
{
using (BinaryWriter bw = new BinaryWriter(fs))
{
bw.Write(zippedStream.ToArray());
}
}
}
Extract file to memeory stream (nuget SevenZipExtractor)
using SevenZipExtractor;
MemoryStream outStream = new MemoryStream();
using (ArchiveFile archiveFile = new ArchiveFile("path of zipped file"))
{
foreach (Entry entry in archiveFile.Entries)
{
//Console.WriteLine(entry.FileName);
//Console.WriteLine("Extract" + outStream.Length);
entry.Extract(outStream);
}
}
Usage of Seven Zip in C#的更多相关文章
- 分享非常有用的Java程序 (关键代码) (三)---创建ZIP和JAR文件
原文:分享非常有用的Java程序 (关键代码) (三)---创建ZIP和JAR文件 import java.util.zip.*; import java.io.*; public class Zip ...
- 20个非常有用的Java程序片段
下面是20个非常有用的Java程序片段,希望能对你有用. 1. 字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric strin ...
- Java程序片段
下面是20个非常有用的Java程序片段,希望能对你有用. 1. 字符串有整型的相互转换 ? 1 2 String a = String.valueOf(2); //integer to numer ...
- java 零碎知识点
1. 字符串有整型的相互转换 1 2 String a = String.valueOf(2); //integer to numeric string int i = Integer.pars ...
- 常用的Java代码汇总
1. 字符串有整型的相互转换 Java 1 2 <strong>Stringa=String.valueOf(2); //integer to numeric ...
- Kooboo中如何切换数据库(注意:如果切换数据库,需要Kooboo中没有一个website 否则会报错数据库中没有表之类的)
Setup database provider 来自Kooboo document Kooboo CMS can almost support all the types of database, ...
- Java开发常用代码
1. 字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric string int i = Integer.parseInt(a) ...
- Java-20个非常有用的程序片段
下面是20个非常有用的Java程序片段,希望能对你有用. 1.字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric string ...
- 20个常用的Java程序块
1.字符串有整型的相互转换 String a = String.valueOf(2);//integer to numeric string Int i = Integer.parseInt(a);/ ...
- 整理:20个非常有用的Java程序片段
下面是20个非常有用的Java程序片段,希望能对你有用. 1. 字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric strin ...
随机推荐
- postgresql的mysql外部数据扩展mysql_fdw编译及安装
下载mysql_fdw项目文件:https://pgxn.org/dist/mysql_fdw/ 注:我使用的是ubuntu18.04,可以直接在仓库查看是否有二级制安装文件,当然是有的啦,这是很方便 ...
- python开发简单的命令行工具
介绍 Python模块argparse,这是一个命令行选项,参数和子命令的解释器,使用该模块可以编写友好的命令行工具,在程序中定义好需要的参数,argparse将弄清楚如何解析 sys.argv中的参 ...
- Mybatis数据库批量操作
1:新增 首先,Mysql插入一条记录返回主键对Mybatis版本要求低,而批量插入返回带主键的,需要升级到3.3.1 以及以上的版本. 1.1:Mysql 上图需要注意加入useGenerate ...
- C# 处理实体类赋值(获取嵌套类型,支持list 自定义类型)
public static T AESEncrypt<T>(T obj) where T : class { if (obj == null) { return obj; } var pr ...
- drf-api接口、测试工具postman
1.web应用模式 """ django是一个web框架,专门用来写web项目,之前学的bbs项目,图书管理系统,用的是前后端混合开发. ""&quo ...
- 《自定义工作流配置,springboot集成activiti,前端vue,完整版审批单据》
前言 activiti工作流引擎项目,企业erp.oa.hr.crm等企事业办公系统轻松落地,一套完整并且实际运用在多套项目中的案例,满足日常业务流程审批需求. 一.项目形式 springboot+v ...
- 【Windows】ip地址修改器v5.0.5.4 修改ip更简便
ip地址修改器v5.0.5.4 修改ip更简便 IP地址修改器,一款能够快速的切换IP地址,在几个不同的固定IP之间进行切换,手动输太麻烦,所以可以用到这款IP地址修改器! 下载 ip地址修改器v5. ...
- DOM简单学习:为了满足案例要求
功能:控制html文档的内容 获取页面标签(元素)对象:Element document.getElementById("id值"):通过元素的id获取元素对象 操作Element ...
- 关于Powerlink和EtherCAT的对比
https://www.amobbs.com/thread-5679636-1-2.html 转发自:http://book.2cto.com/201508/55093.html 这个问题经常会被人问 ...
- 郁金香 中级班 1.c++的类和对象
#include<stdio.h> class 生物 { public: 生物() { printf("我是构造函数\n"); } int id1; int id2; ...