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 ...
随机推荐
- Nacos服务注册原理分析
在分布式服务中,原来的单体服务会被拆分成一个个微服务,服务注册实例到注册中心,服务消费者通过注册中心获取实例列表,直接请求调用服务. 服务是如何注册到注册中心,服务如果挂了,服务是如何检测?带着这些问 ...
- 如何修剪git reflog历史
背景: vscode插件git-graph可以方便查看git-commit-graph,效果很好,关键是交互性很好.点选任意commit即可预览提交内容,实在是太方便了,比我之前用命令行上git lo ...
- JAVA虚拟机05-内存溢出示例(jdk1.8)
1.JAVA虚拟机堆内存溢出OutOfMemoryError 1.1设置参数 -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError 最小堆的大小20m 最大堆 ...
- 【爬虫+数据清洗+可视化分析】舆情分析哔哩哔哩"狂飙"的评论
目录 一.背景介绍 二.爬虫代码 2.1 展示爬取结果 2.2 爬虫代码讲解 三.可视化代码 3.1 读取数据 3.2 数据清洗 3.3 可视化 3.3.1 IP属地分析-柱形图 3.3.2 评论时间 ...
- 国际财务系统基于ShardingSphere的数据分片和一主多从实践
作者:京东物流 张广治 1 背景 传统的将数据集中存储至单一数据节点的解决方案,在性能和可用性方面已经难于满足海量数据的场景,系统最大的瓶颈在于单个节点读写性能,许多的资源受到单机的限制,例如连接数. ...
- 逆天的Zstack-工控机上测试
放假前一直在服务器上折腾Zstack跑数据库,调IOC.正好手头有个32G内存,intel i7处理器的工控机,就试试装Zstack跑跑看,想着即使重负荷的跑不了,跑跑docker之类的也行.装成功后 ...
- 修改Element - plus的样式
把显示再浏览器上的对应css选择器全部写上,并且添加 !important </script> <style lang='scss' scoped> //修改 element ...
- Ansible 快速入门到放弃
Ansible 快速入门到放弃 最是人间留不住,朱颜辞镜花辞树. 1-Ansible 简介 Ansible是一个配置管理和配置工具,它使用SSH 连接到服务器并运行配置好的任务,服务器上只需要开启ss ...
- 音频处理库:pydub与ffmpeg
一句话简介:pydub--音频处理库:ffmpeg--音视频编解码工具. 一. 安装 安装pydub pip install pydub pip install ffprobe 安装ffmpeg m ...
- openfoam UPstream类探索(二)
前言 接上次的博文,本篇补全以下几个函数的介绍: Pstream::nProcs() Pstream::parRun() UPstream::exit() 简述几个常用的函数如下: Pstream:: ...