[Bug][0.41.0] ZipArchive.ExtractToDirectory method not work #717

Closed
opened 2026-01-29 22:16:21 +00:00 by claunia · 7 comments
Owner

Originally created by @aaasoft on GitHub (Nov 14, 2025).

Recently,I update SharpComporess from 0.40.0 to 0.41.0 in my project.
I found ZipArchive.ExtractToDirectory method not work.
No file extracted and no exception throwed,nothing happen.

Test Zip file: https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/10.0.0/aspnetcore-runtime-10.0.0-win-x64.zip
Test code:

using (var archive = SharpCompress.Archives.Zip.ZipArchive.Open("aspnetcore-runtime-10.0.0-win-x64.zip")) archive.ExtractToDirectory("Test");

Originally created by @aaasoft on GitHub (Nov 14, 2025). Recently,I update SharpComporess from 0.40.0 to 0.41.0 in my project. I found ZipArchive.ExtractToDirectory method not work. No file extracted and no exception throwed,nothing happen. Test Zip file: https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/10.0.0/aspnetcore-runtime-10.0.0-win-x64.zip Test code: `using (var archive = SharpCompress.Archives.Zip.ZipArchive.Open("aspnetcore-runtime-10.0.0-win-x64.zip")) archive.ExtractToDirectory("Test");`
Author
Owner

@adamhathcock commented on GitHub (Nov 14, 2025):

Works for me. This example will always put a Test directory in your build output

Image
@adamhathcock commented on GitHub (Nov 14, 2025): Works for me. This example will always put a Test directory in your build output <img width="404" height="546" alt="Image" src="https://github.com/user-attachments/assets/ef95c9e2-00ef-46f4-a54e-ca9059c21508" />
Author
Owner

@aaasoft commented on GitHub (Nov 14, 2025):

@adamhathcock You tested on mac os,but I tested on Windows 10,the bug is still there.

I add some output and a stopwatch,here is my last test code:

using SharpCompress.Archives;
using SharpCompress.Archives.Zip;
using System.Diagnostics;
using System.Runtime.InteropServices;

var zipFile = "aspnetcore-runtime-10.0.0-win-x64.zip";
var folder = "Test";

//Print info
Console.WriteLine("SharpCompress version: " + typeof(ZipArchive).Assembly.GetName().Version);
Console.WriteLine("OS: " + RuntimeInformation.OSDescription);
Console.WriteLine("Framework: " + RuntimeInformation.FrameworkDescription);
Console.WriteLine("-------------");

//Cleanup
if (Directory.Exists(folder))
    Directory.Delete(folder, true);

//Decompress
Console.WriteLine($"Begin decompress....");
var stopwatch = new Stopwatch();
stopwatch.Start();
using (var archive = ZipArchive.Open(zipFile))
    archive.ExtractToDirectory(folder);
stopwatch.Stop();
Console.WriteLine($"Decompress done,used time: {stopwatch.Elapsed}");

//Check if folder exists
Console.WriteLine($"Folder exists: {Directory.Exists(folder)}");

Version 0.40.0 test result:

SharpCompress version: 0.40.0.0
OS: Microsoft Windows 10.0.19045
Framework: .NET 8.0.22
-------------
Begin decompress....
Decompress done,used time: 00:00:00.8712567
Folder exists: True

Version 0.41.0 test result:

SharpCompress version: 0.41.0.0
OS: Microsoft Windows 10.0.19045
Framework: .NET 8.0.22
-------------
Begin decompress....
Decompress done,used time: 00:00:00.0298282
Folder exists: False
@aaasoft commented on GitHub (Nov 14, 2025): @adamhathcock You tested on mac os,but I tested on Windows 10,the bug is still there. I add some output and a stopwatch,here is my last test code: ``` using SharpCompress.Archives; using SharpCompress.Archives.Zip; using System.Diagnostics; using System.Runtime.InteropServices; var zipFile = "aspnetcore-runtime-10.0.0-win-x64.zip"; var folder = "Test"; //Print info Console.WriteLine("SharpCompress version: " + typeof(ZipArchive).Assembly.GetName().Version); Console.WriteLine("OS: " + RuntimeInformation.OSDescription); Console.WriteLine("Framework: " + RuntimeInformation.FrameworkDescription); Console.WriteLine("-------------"); //Cleanup if (Directory.Exists(folder)) Directory.Delete(folder, true); //Decompress Console.WriteLine($"Begin decompress...."); var stopwatch = new Stopwatch(); stopwatch.Start(); using (var archive = ZipArchive.Open(zipFile)) archive.ExtractToDirectory(folder); stopwatch.Stop(); Console.WriteLine($"Decompress done,used time: {stopwatch.Elapsed}"); //Check if folder exists Console.WriteLine($"Folder exists: {Directory.Exists(folder)}"); ``` Version 0.40.0 test result: ``` SharpCompress version: 0.40.0.0 OS: Microsoft Windows 10.0.19045 Framework: .NET 8.0.22 ------------- Begin decompress.... Decompress done,used time: 00:00:00.8712567 Folder exists: True ``` Version 0.41.0 test result: ``` SharpCompress version: 0.41.0.0 OS: Microsoft Windows 10.0.19045 Framework: .NET 8.0.22 ------------- Begin decompress.... Decompress done,used time: 00:00:00.0298282 Folder exists: False ```
Author
Owner

@Morilli commented on GitHub (Nov 14, 2025):

The underlying cause for this issue is the same as in #960.

@Morilli commented on GitHub (Nov 14, 2025): The underlying cause for this issue is the same as in #960.
Author
Owner

@aaasoft commented on GitHub (Nov 15, 2025):

I tested on Debain.Also has this bug.

Version 0.40.0 test result:

SharpCompress version: 0.40.0.0
OS: Debian GNU/Linux 12 (bookworm)
Framework: .NET 8.0.22
-------------
Begin decompress....
Decompress done,used time: 00:00:01.4328794
Folder exists: True

Version 0.41.0 test result:

SharpCompress version: 0.41.0.0
OS: Debian GNU/Linux 12 (bookworm)
Framework: .NET 8.0.22
-------------
Begin decompress....
Decompress done,used time: 00:00:00.0396758
Folder exists: False
@aaasoft commented on GitHub (Nov 15, 2025): I tested on Debain.Also has this bug. Version 0.40.0 test result: ``` SharpCompress version: 0.40.0.0 OS: Debian GNU/Linux 12 (bookworm) Framework: .NET 8.0.22 ------------- Begin decompress.... Decompress done,used time: 00:00:01.4328794 Folder exists: True ``` Version 0.41.0 test result: ``` SharpCompress version: 0.41.0.0 OS: Debian GNU/Linux 12 (bookworm) Framework: .NET 8.0.22 ------------- Begin decompress.... Decompress done,used time: 00:00:00.0396758 Folder exists: False ```
Author
Owner

@aaasoft commented on GitHub (Nov 15, 2025):

The underlying cause for this issue is the same as in #960.

@adamhathcock @Morilli ZIP file is not SOLID.I think IArchive.ExtractToDirectory method should work with any archive files,not just SOLID archives.

Is this commit cause this bug?
make WriteToDirectory functions use ExtractAllEntries

@aaasoft commented on GitHub (Nov 15, 2025): > The underlying cause for this issue is the same as in [#960](https://github.com/adamhathcock/sharpcompress/issues/960). @adamhathcock @Morilli ZIP file is not SOLID.I think IArchive.ExtractToDirectory method should work with any archive files,not just SOLID archives. Is this commit cause this bug? [make WriteToDirectory functions use ExtractAllEntries](https://github.com/adamhathcock/sharpcompress/commit/bbeb46b37f0d453a32deb23011f961247a3eb510)
Author
Owner

@adamhathcock commented on GitHub (Nov 19, 2025):

I still an extract on Windows fine it seems

Image
@adamhathcock commented on GitHub (Nov 19, 2025): I still an extract on Windows fine it seems <img width="795" height="347" alt="Image" src="https://github.com/user-attachments/assets/0bfb9d3f-2098-4fb6-8de3-ce66e108ec3f" />
Author
Owner

@aaasoft commented on GitHub (Dec 2, 2025):

I found this bug fixed in version 0.42.0

@aaasoft commented on GitHub (Dec 2, 2025): I found this bug fixed in version 0.42.0
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#717