Skip to content

Make SevenZipExtractor adapt for Costura.Fody. C# 可配合 Costura.Fody 使用的 SevenZipExtractor

License

Notifications You must be signed in to change notification settings

qwqcode/SevenZipExtractor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SevenZipExtractor

可配合 Costura.Fody 使用的 SevenZipExtractor

C# SevenZipExtractor with Costura.Fody

How To Do ?

A = 当前的 SevenZipExtractor 项目

B = 目标项目 将调用 SevenZipExtractor(已引用 Costura.Fody

在此之前 B 先 NeGet 搜索引用 Costura.Fody,B 目录中将出现 FodyWeavers.xml

  1. git clone 打开解决方案,解决方案资源管理器 选中 SevenZipExtractor 右键 生成,SevenZipExtractor.dll 将会出现在 A/bin/Release/

  2. 复制 A 目录/bin/Release/SevenZipExtractor.dllB 目录

  3. B 中引用 SevenZipExtractor.dll 并配置 复制本地=False 如图

    20180206134927

    20180206135034

  4. B 中创建目录 Costura32Costura64 并将 A 目录/bin/Release/(x86|x64)/7z.dll 对应放入其中,对 .dll 文件进行配置 生成操作=嵌入的资源, 复制到输出目录=不复制 如图所示

    20180206135058

  5. 配置 FodyWeavers.xml

    <Weavers>
      <Costura CreateTemporaryAssemblies='true'
               Unmanaged32Assemblies='7z|SevenZipExtractor'
               Unmanaged64Assemblies='7z|SevenZipExtractor'
               IncludeAssemblies='SevenZipExtractor'/>
    </Weavers>

    20180206135305

  6. 好啦好啦 清理 再 生成 B 即可。现在就只有一个文件了,7z.dllSevenZipExtractor.dll 都已嵌入单个 .exe

    20180206135433

Original Introduction

C# wrapper for 7z.dll (x86 and x64 included)

Based on code from: http://www.codeproject.com/Articles/27148/C-NET-Interface-for-Zip-Archive-DLLs

Supported formats:

  • 7Zip
  • APM
  • Arj
  • BZip2
  • Cab
  • Chm
  • Compound
  • Cpio
  • CramFS
  • Deb
  • Dll
  • Dmg
  • Exe
  • Fat
  • Flv
  • GZip
  • Hfs
  • Iso
  • Lzh
  • Lzma
  • Lzma86
  • Mach-O
  • Mbr
  • Mub
  • Nsis
  • Ntfs
  • Ppmd
  • Rar
  • Rar5
  • Rpm
  • Split
  • SquashFS
  • Swf
  • Swfc
  • Tar
  • TE
  • Udf
  • UEFIc
  • UEFIs
  • Vhd
  • Wim
  • Xar
  • XZ
  • Z
  • Zip

NuGet

Install-Package SevenZipExtractor

Examples

using (ArchiveFile archiveFile = new ArchiveFile(@"Archive.ARJ"))
{
    archiveFile.Extract("Output"); // extract all
}
using (ArchiveFile archiveFile = new ArchiveFile(@"Archive.ARJ"))
{
    foreach (Entry entry in archiveFile.Entries)
    {
        Console.WriteLine(entry.FileName);
        
        // extract to file
        entry.Extract(entry.FileName);
        
        // extract to stream
        MemoryStream memoryStream = new MemoryStream();
        entry.Extract(memoryStream);
    }
}

7z.dll

7z.dll (x86 and x64) will be added to your BIN folder automatically.

License

About

Make SevenZipExtractor adapt for Costura.Fody. C# 可配合 Costura.Fody 使用的 SevenZipExtractor

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.2%
  • PowerShell 0.8%