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 CentOS7查看软件包安装时间

    rpm -qi 软件包名,比如httpd,lrzsz [devops@host9 ~]$ rpm -qi lrzsz Name : lrzsz Version : 0.12.20 Release : ...

  2. 一篇文章带你掌握Flex布局的所有用法

    Flex 布局目前已经非常流行了,现在几乎已经兼容所有浏览器了.在文章开始之前我们需要思考一个问题:我们为什么要使用 Flex 布局? 其实答案很简单,那就是 Flex 布局好用.一个新事物的出现往往 ...

  3. MySQL-SQL语句查询关键字

    1.SQL语句查询关键字 1.select:指定需要查找的字段信息,eg:select *,select name.同时select也支持对字段做处理,eg:select char_length(na ...

  4. 力扣---45. 跳跃游戏 II

    给定一个长度为 n 的 0 索引整数数组 nums.初始位置为 nums[0].每个元素 nums[i] 表示从索引 i 向前跳转的最大长度.换句话说,如果你在 nums[i] 处,你可以跳转到任意 ...

  5. .NET 支付宝SDK新版 AlipayEasySDK 配置文件详细说明

    config代码: using Tea; namespace Alipay.EasySDK.Kernel { /// <summary> /// 客户端配置参数模型 /// </su ...

  6. 4.12 疫情数据可视化 毕设(初稿版 crud+可视化echarts

    4.22 完成地图 数据可视化~~~  599x150 解决不显示图片的问题 参考文档 https://blog.csdn.net/qq_51917985/article/details/121380 ...

  7. MySQL 版本号排序

    1.业务背景 版本检查接口返回版本号排序时出现如下图所示问题 普通的查询按数字值逐级比较,导致版本号高的排在了后面,这样版本检查根据版本号排序倒排取出来的不是最新的版本号,本文就此问题查询了诸多方法, ...

  8. soucrce insight4 使用

    1.快捷键 F8 高亮 ctrl + 左击 进入函数定义或变量声明处 Alt + , 后退 Alt + . 前进 ctrl + g 跳到固定行 shift + F3 选中一个单词按下后,可按F3,F4 ...

  9. JZOJ 3252. 【GDOI三校联考】炸弹

    思路 注:上图只是个例子,其实建图时 \(5\) 是不会连向 \(6\) 的 \(Code\) #include<cstdio> #include<cstring> #incl ...

  10. KMP字符串 AcWing 831

    题目:https://www.acwing.com/problem/content/833/ 题意:求子串在母串中每次出现时的下标位置. 题解:哈哈哈,敲题时想到之前看到一个人叫 kmp 算法为 看毛 ...