Skip to content

adoconnection/SevenZipExtractor

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
January 14, 2020 11:07
January 14, 2020 11:07
April 8, 2022 14:28
October 5, 2017 11:57
April 19, 2022 20:25
April 8, 2022 14:28
April 8, 2022 14:30
January 17, 2022 15:25

SevenZipExtractor

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

  • .NET Standard 2.0
  • .NET Framework 4.5

NuGet NuGet

Every single star makes maintainer happy!

NuGet

Install-Package SevenZipExtractor

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

Examples

Extract all

using (ArchiveFile archiveFile = new ArchiveFile(@"Archive.ARJ"))
{
    archiveFile.Extract("Output"); // extract all
}

Extract to file or stream

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);
    }
}

Guess archive format from files without extensions

using (ArchiveFile archiveFile = new ArchiveFile(@"c:\random-archive"))
{
    archiveFile.Extract("Output"); 
}

Guess archive format from streams

WebRequest request = WebRequest.Create ("http://www.contoso.com/file.aspx?id=12345");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

using (ArchiveFile archiveFile = new ArchiveFile(response.GetResponseStream())
{
    archiveFile.Extract("Output"); 
}

Wiki

7z.dll

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

License

Changelog

1.0.17 / 2022.04.08

  • #54 4Gb+ archives fixed! 🎉 (Thanks Pyroluk)

1.0.16 / 2021.01.17

  • 7z binaries updated to 21.07.0.0
  • PR#56 - signature for SquashFS (Thanks mmoosstt)
  • PR#53 - look for binaries in bin folder (Thanks CupSunshine)

1.0.15 / 2020.01.14

  • .NETStandard 2.0 support PR#38

1.0.14

  • Entry.Extrat - preserveTimestamp is true by default #34
  • Dynamic operations can only be performed in homogenous AppDomain" #36