sharpcompress: NotSupportedException for 7zip Archive using Ultra Compression

I zipped up a file using 7zip (file manager / GUI). I tried with both LZMA and LZMA2, using ultra compression. I can’t seem to figure out how to extract it; I always get a NotSupportedException.

Here are the two snippets I tried with the archiving API, which supposedly works?

                // 1) Archive API? not supported exception.
                var archive = ArchiveFactory.Open(archivePath);
                archive.WriteToDirectory(outPath, options);

                // 2) Archive API: not supported exception
                var archive = ArchiveFactory.Open(archivePath);
                foreach (var entry in archive.Entries.Where(e => !e.IsDirectory))
                {
                    entry.WriteToDirectory(outPath, options);
                }

I think they fail with the same exception. Here’s the stack trace for the second one:

Exception has occurred: CLR/System.NotSupportedException
An unhandled exception of type 'System.NotSupportedException' occurred in SharpCompress.dll: 'Specified method is not supported.'
   at SharpCompress.Compressors.LZMA.DecoderRegistry.CreateDecoderStream(CMethodId id, Stream[] inStreams, Byte[] info, IPasswordProvider pass, Int64 limit)
   at SharpCompress.Compressors.LZMA.DecoderStreamHelper.CreateDecoderStream(Stream inStream, Int64 startPos, Int64[] packSizes, CFolder folderInfo, IPasswordProvider pass)
   at SharpCompress.Common.SevenZip.ArchiveDatabase.GetFolderStream(Stream stream, CFolder folder, IPasswordProvider pw)
   at SharpCompress.Common.SevenZip.SevenZipFilePart.GetCompressedStream()
   at SharpCompress.Archives.SevenZip.SevenZipArchiveEntry.OpenEntryStream()
   at SharpCompress.Archives.IArchiveEntryExtensions.WriteTo(IArchiveEntry archiveEntry, Stream streamToWriteTo)
   at SharpCompress.Archives.IArchiveEntryExtensions.<>c__DisplayClass2_0.<WriteToFile>b__0(String x, FileMode fm)
   at SharpCompress.Common.ExtractionMethods.WriteEntryToFile(IEntry entry, String destinationFileName, ExtractionOptions options, Action`2 openAndWrite)
   at SharpCompress.Archives.IArchiveEntryExtensions.WriteToFile(IArchiveEntry entry, String destinationFileName, ExtractionOptions options)
   at SharpCompress.Common.ExtractionMethods.WriteEntryToDirectory(IEntry entry, String destinationDirectory, ExtractionOptions options, Action`2 write)
   at SharpCompress.Archives.IArchiveEntryExtensions.WriteToDirectory(IArchiveEntry entry, String destinationDirectory, ExtractionOptions options)

I’m sure it must be something I’m doing wrong (perhaps in my 7zip archive creation?) but I can’t figure out what or how to make this work.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@TraceEntertains , I would like to know if you have a test file that fails with the pull request I created. the current test contains the general setup of files used in the test suite and that passed.

Both my delta test file and the original archive it was based on extracted seemingly perfectly, and the music files were the quickest to extract out of almost all other files that I could tell.