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 ...
随机推荐
- Linux音频采集和在国产化平台中遇到的坑(二)
Linux音频采集和在国产化平台中遇到的坑(二) ALSA采集这条路走不通,只能尝试其他途径,这里通过PulseAudio的接口成功实现了采集麦克风和系统声音的功能. linux PulseAudio ...
- Linux环境下:程序的链接, 装载和库[静态链接]
看以下例子 main.c extern int x; int main() { int y = 100; swap(&x,&y); return 0; } int x = 1; voi ...
- 聊聊JUC包下的底层支撑类-AbstractQueuedSynchronizer(AQS)
聊聊JUC包下的底层支撑类-AbstractQueuedSynchronizer(AQS) juc包下的一堆并发工具类是我们日常开发特别是面试中常被拿来问的八股文之一,为了工作也好,为了面试也罢,今天 ...
- 复杂环境下ocr与印章识别技术理解及研发趋势
引言 随着社会经济的发展,印章作为企事业单位.社会团体.政府部门乃至国家的一种具有法律意义的标志和证据,在现代社会生活中发挥着重要作用.随着现代商务活动的不断发展,企业在业务开展的过程中通常会涉及大量 ...
- drf-api接口、测试工具postman
1.web应用模式 """ django是一个web框架,专门用来写web项目,之前学的bbs项目,图书管理系统,用的是前后端混合开发. ""&quo ...
- TCP/IP协议(5): IP(Internet Protocol) 协议 —— 连接各个网络的协议
TCP/IP协议(5): IP(Internet Protocol) 协议 -- 连接各个网络的协议 关于 IP(Internet Protocol) 协议 IP(Internet Protocol) ...
- JZOJ 1073. 【GDOI2005】山海经
\(\text{Solution}\) 非常经典的求区间最大字段和 不难想到线段树,考虑处理区间答案的合并 维护前缀后缀最大和与区间答案,合并考虑跨中点贡献即可 代码打得非常恶心... \(\text ...
- Prufer序列 学习笔记
\(Prufer\) 序列 \(\texttt{definition}\) \(Prufer\) 序列序列可以将一个带标号 \(n\) 个结点的树用 \([1..n]\) 中的 \(n-2\) 个整数 ...
- 解决ssh连接远程主机出现“REMOTE HOST IDENTIFICATION HAS CHANGED”问题
Win通过ssh连接远程主机 命令提示符方式 ssh username@ip 此后输入你的密码 通过VSCode Remote-SSH 在VSCode拓展中搜索"Remote-SSH&quo ...
- iview表单验证
iview表单验证的步骤 第一步:给 Form 设置属性 rules :rules="规则设置" 第二步:同时给需要验证的每个 FormItem 设置属性 prop 指向对应字段即 ...