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#的更多相关文章

  1. 分享非常有用的Java程序 (关键代码) (三)---创建ZIP和JAR文件

    原文:分享非常有用的Java程序 (关键代码) (三)---创建ZIP和JAR文件 import java.util.zip.*; import java.io.*; public class Zip ...

  2. 20个非常有用的Java程序片段

    下面是20个非常有用的Java程序片段,希望能对你有用. 1. 字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric strin ...

  3. Java程序片段

    下面是20个非常有用的Java程序片段,希望能对你有用. 1. 字符串有整型的相互转换 ? 1 2 String a = String.valueOf(2);   //integer to numer ...

  4. java 零碎知识点

    1. 字符串有整型的相互转换 1 2 String a = String.valueOf(2);   //integer to numeric string  int i = Integer.pars ...

  5. 常用的Java代码汇总

    1. 字符串有整型的相互转换           Java   1 2 <strong>Stringa=String.valueOf(2);   //integer to numeric ...

  6. Kooboo中如何切换数据库(注意:如果切换数据库,需要Kooboo中没有一个website 否则会报错数据库中没有表之类的)

    Setup database provider 来自Kooboo document   Kooboo CMS can almost support all the types of database, ...

  7. Java开发常用代码

    1. 字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric string int i = Integer.parseInt(a) ...

  8. Java-20个非常有用的程序片段

    下面是20个非常有用的Java程序片段,希望能对你有用. 1.字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric string ...

  9. 20个常用的Java程序块

    1.字符串有整型的相互转换 String a = String.valueOf(2);//integer to numeric string Int i = Integer.parseInt(a);/ ...

  10. 整理:20个非常有用的Java程序片段

    下面是20个非常有用的Java程序片段,希望能对你有用. 1. 字符串有整型的相互转换 String a = String.valueOf(2); //integer to numeric strin ...

随机推荐

  1. 【分析笔记】Linux input 子系统原理分析

    一.input 子系统简介 输入子系统主要用于支持各种输入设备,可大大简化这类设备驱动的开发难度.以下为个人的理解,可能不同的内核版本会略有差异,在这里分析的内核为 linux-4.9. 无论在 Li ...

  2. docker05-dockerfile

    1.dockerfile是什么 Dockerfile是用来构建Docker镜像的构建文件,是由一系列命令和参数构成的脚本.可以理解为docker自己的语言编写的脚本. 2.Dockerfile内容基础 ...

  3. spring cloud alibaba sentinel 运行及简单使用

    1.官网 英文:https://github.com/alibaba/Sentinel 中文:https://github.com/alibaba/Sentinel/wiki/%E4%BB%8B%E7 ...

  4. Autodesk Maya2023 破解版安装教程(小白看了也说understand)

    前言 Maya是Autodesk旗下的著名三维建模和动画软件,应用对象是专业的影视广告,角色动画,电影特技等.Maya功能完善,工作灵活,制作效率极高,渲染真实感极强,是电影级别的高端制作软件. 安装 ...

  5. imax6开发版_挂载NFS文件系统

    挂载:mount -o vers=4 192.168.30.108:/home/penuel/linux_imax6/workdir /home/root/workdir 取消挂载:umount /h ...

  6. NOIP 模拟赛 简单题

    \(\text{Solution}\) 发现题目就是求 \(\sum[\prod_{i=1}^k x_i \le n]\) \(k \le 10^9\) 太可怕了 然而发现如果限定 \(x_i > ...

  7. JZOJ 3448.公路维护

    \(\text{Problem}\) 1.询问区间最小值是否大于 \(0\) 2.区间加(可正可负) 3.区间取 \(\max\) 如果某个数经过操作后小于等于 \(0\),以后的操作就不会再影响这个 ...

  8. JZOJ 2936. 【NOIP2012模拟8.9】逐个击破

    题面 各大 \(OJ\) 都有 分析 从结果入手:所有被敌方军团占领的城市都是分开的 而按最小代价删去若干条边,则剩下的图必然是若干个联通子图组成的 那么我们要使花费最小,可以是留下的边最大 并查集合 ...

  9. Prime Distance

    Description The branch of mathematics called number theory is about properties of numbers. One of th ...

  10. postgresql VACUUM 不会从表中删除死行的三个原因

    一.为什么是VACUUM? 每当更新或删除PostgreSQL表中的行时,都会留下死元组.VACUUM摆脱了它们,以便空间可以重复使用.如果一个表没有被清理,它就会变得臃肿,这会浪费磁盘空间并减慢表的 ...