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. 非代码的贡献也能成为Committer,我与DolphinScheduler社区的故事

    点亮 ️ Star · 照亮开源之路 https://github.com/apache/dolphinscheduler   ​   // 每个人对于"开源社区"的定义都不一样, ...

  2. v-html渲染页面的时候 css样式无效

    感谢: https://www.cnblogs.com/niuxiaoxian/p/9443873.html 当我们用v-html渲染页面的时候会发现样式并没有添加上,如下 复制代码 <temp ...

  3. P9_组件-swiper和swiper-item的基本用法

    swiper 和 swiper-item 组件的基本使用 实现如图的轮播图效果: swiper 组件的常用属性 list.wxml <swiper class="swiper-cont ...

  4. 怎么在GridView中限制显示字数

    三种方法可以实现,前两种是C#代码实现(原理一样),第三种是CSS实现. 1.cs代码中:GridView的RowDataBound中对想做处理的项做Remove()字符串截取. 2.aspx页面中: ...

  5. 如何快速搭建 Maven私服Nexus【实践可行版】

    搭建私服Nexus Nexus 一般用来搭建位于组织或公司内部的 Maven 私服,代理所有的仓库(包括中央仓库),用户通过它就可以获取和管理所有所需的 Maven 构件. Nexus 开源版具有以下 ...

  6. C4模型,架构设计图的脚手架,你值得拥有

    hi,我是熵减,见字如面. 对于软件开发团队来说,写软件设计文档,花架构图,是日常工作中的关键一项. 而其中,如何画好系统设计的架构图呢? Simon Brown 就 提出 C4 模型,来解决这个问题 ...

  7. JZOJ 2022.02.11【提高A组】模拟

    \(\text{Solution}\) 首先把 \(T2\) 给切了,\(T1\) 找半天规律找不到 然后打了个表算是暴力了 \(T3\) 也暴... 太暴了... \(T4\) 直接啥也不会 \(\ ...

  8. 【Gerald and Giant Chess】

    一道计数类DP例题~~~ ps:P党似乎不多了-- 我这只蒟蒻第一次写题解,而且计数类DP还是早上刚学的,现学现用,或者说是所谓的"浅谈"一番吧!况且这题写题解的人似乎并不多(大佬 ...

  9. Luogu P3919 【模板】可持久化线段树 1(可持久化数组)

    板子,正好温习一下主席树的写法 记得数组开 \(32\) 倍!! \(Code\) #include<cstdio> using namespace std; const int N = ...

  10. FreeFileSync:开源的文件同步工具 | Linux 中国

    转载知乎: https://zhuanlan.zhihu.com/p/194778373