Simply execute following code:
using Aspose.Zip;
using System.Reflection;
namespace AsposeZipTest
{
internal class Program
{
static void Main(string[] args)
{
Assembly asm = Assembly.GetExecutingAssembly();
using Stream? aStream = asm.GetManifestResourceStream("AsposeZipTest.Aspose.Total.lic");
License lic = new();
lic.SetLicense(aStream);
Console.WriteLine("Generating 10 GB temporary file...");
string tempFilePath = Path.Combine(Path.GetTempPath(), $"garbage_{Guid.NewGuid()}.tmp");
string compressedFilePath = tempFilePath.Replace(".tmp", ".zip");
GenerateTestFile(tempFilePath);
CompressFileWithAsposeZip(tempFilePath,compressedFilePath);
File.Delete(tempFilePath);
try
{
DecompressFileWithAsposeZip(compressedFilePath);
}
catch (Exception ex)
{
Console.WriteLine("Error during decompression: " + ex.Message);
Console.WriteLine("");
Console.WriteLine(@"Error Analysis
Root Cause: The error occurs when trying to decompress a large 5GB ZIP archive file. The Aspose.Zip library is incorrectly interpreting the ZIP64 central directory structure as a multi-volume (spanned) archive, throwing a NotImplementedException with the message ""Archive with the central directory spread across volumes is not implemented yet.""
Why This Happens:
1. The archive file is 5,268,484,228 bytes (~4.9 GB), which requires ZIP64 format extensions
2. When Aspose.Zip reads the file, it seeks to the end to find the central directory
3. The stream position (5,268,484,186) shows Aspose.Zip has read to near the end of the file
4. The remaining 42 bytes match the size of ZIP64 End of Central Directory structures
5. Aspose.Zip's ZIP64 parser is misidentifying certain ZIP64 structures as multi-volume archive signatures
6. This is likely a bug or limitation in the Aspose.Zip library when handling certain ZIP64 files created by specific tools or with specific options
The Current Code Issue: The retry logic in DecompressStream(Stream, Stream, string) only catches InvalidDataException for the 4-byte offset retry, but this exception is NotImplementedException, so the fallback to System.IO.Compression never runs. Additionally, the fallback is skipped for files >2GB, but System.IO.Compression in .NET Core actually supports ZIP64 well.");
}
}
private static void GenerateTestFile(string tempFilePath)
{
long fileSizeInBytes = 10L * 1024 * 1024 * 1024; // 10 GB
int bufferSize = 1024 * 1024; // 1 MB buffer
byte[] buffer = new byte[bufferSize];
// Fill buffer with random data
Random random = new Random();
random.NextBytes(buffer);
try
{
using (FileStream fs = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
{
long bytesWritten = 0;
while (bytesWritten < fileSizeInBytes)
{
long remaining = fileSizeInBytes - bytesWritten;
int toWrite = (int)Math.Min(bufferSize, remaining);
fs.Write(buffer, 0, toWrite);
bytesWritten += toWrite;
// Progress indicator
if (bytesWritten % (100 * 1024 * 1024) == 0) // Every 100 MB
{
Console.WriteLine($"Written: {bytesWritten / (1024 * 1024)} MB / {fileSizeInBytes / (1024 * 1024)} MB");
}
}
}
Console.WriteLine($"File created successfully: {tempFilePath}");
Console.WriteLine($"File size: {new FileInfo(tempFilePath).Length / (1024.0 * 1024 * 1024):F2} GB");
}
catch (Exception ex)
{
Console.WriteLine($"Error creating file: {ex.Message}");
}
}
private static void CompressFileWithAsposeZip(string tempFilePath,string compressedFilePath)
{
try
{
Console.WriteLine($"\nCompressing file with Aspose.Zip...");
using (Archive archive = new Archive())
{
archive.CreateEntry(Path.GetFileName(tempFilePath), tempFilePath);
archive.Save(compressedFilePath);
}
FileInfo originalFile = new FileInfo(tempFilePath);
FileInfo compressedFile = new FileInfo(compressedFilePath);
Console.WriteLine($"Compression completed successfully!");
Console.WriteLine($"Original file: {tempFilePath}");
Console.WriteLine($"Original size: {originalFile.Length / (1024.0 * 1024 * 1024):F2} GB");
Console.WriteLine($"Compressed size: {compressedFile.Length / (1024.0 * 1024 * 1024):F2} GB");
Console.WriteLine($"Compression ratio: {(1 - (double)compressedFile.Length / originalFile.Length) * 100:F2}%");
}
catch (Exception ex)
{
Console.WriteLine($"Error compressing file: {ex.Message}");
}
}
private static void DecompressFileWithAsposeZip(string compressedFilePath)
{
Console.WriteLine($"\nDecompressing file with Aspose.Zip...");
string extractionPath = Path.Combine(Path.GetDirectoryName(compressedFilePath) ?? Path.GetTempPath(), "extracted");
Directory.CreateDirectory(extractionPath);
using Archive archive = new Archive(compressedFilePath);
archive.ExtractToDirectory(extractionPath);
Console.WriteLine($"Decompression completed successfully!");
Console.WriteLine($"Extracted to: {extractionPath}");
Console.WriteLine($"Number of files extracted: {archive.Entries.Count}");
foreach (ArchiveEntry? entry in archive.Entries)
{
string extractedFilePath = Path.Combine(extractionPath, entry.Name);
if (File.Exists(extractedFilePath))
{
FileInfo extractedFile = new FileInfo(extractedFilePath);
Console.WriteLine($" - {entry.Name}: {extractedFile.Length / (1024.0 * 1024 * 1024):F2} GB");
}
}
}
}
}
You will get exception about NotImplementedException: “Archive with the central directory spread across volumes”