[PR #750] Add fast ExtractToDirectoryAsync extension method on IArchive #1207

Closed
opened 2026-01-29 22:19:29 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/adamhathcock/sharpcompress/pull/750

State: closed
Merged: Yes


As mentioned in #728 (and I believe some other issues), the IArchive.WriteToDirectory(...) extension method can be very slow for .7z files. This extension utilized IArchive.ExtractAllEntries() and IReader so is fast for .7z files.

Being async has nothing to do with the performance, rather, it's because I use this extension method from an async method and need it to perform the long-running work asynchronously. Ideally IArchive.ExtractAllEntries() and IReader.WriteEntryTo(Stream) would be async as well and then the whole Task.Run wouldn't be needed and then it would make more sense to be async.

It currently doesn't support ExtractionOptions or reporting progress through IArchive's events (although it does report progress through a callback). But, it works great as-is for my use case, which I suspect is pretty common, and I wanted to share.

**Original Pull Request:** https://github.com/adamhathcock/sharpcompress/pull/750 **State:** closed **Merged:** Yes --- As mentioned in #728 (and I believe some other issues), the `IArchive.WriteToDirectory(...)` extension method can be very slow for `.7z` files. This extension utilized `IArchive.ExtractAllEntries()` and `IReader` so is fast for .7z files. Being async has nothing to do with the performance, rather, it's because I use this extension method from an async method and need it to perform the long-running work asynchronously. Ideally `IArchive.ExtractAllEntries()` and `IReader.WriteEntryTo(Stream)` would be async as well and then the whole Task.Run wouldn't be needed and then it would make more sense to be async. It currently doesn't support `ExtractionOptions` or reporting progress through `IArchive`'s events (although it does report progress through a callback). But, it works great as-is for my use case, which I suspect is pretty common, and I wanted to share.
claunia added the pull-request label 2026-01-29 22:19:29 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1207