From c48409c9038786bb65fc3a106adaf1a738ec5840 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Sat, 22 Mar 2025 16:50:15 +0100 Subject: [PATCH] Update USAGE.md added an explanatory comment to the ExtractAllEntries usage and removed the problematic previous code. I've added a new example for iterating over entries that doesn't extract them. --- USAGE.md | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/USAGE.md b/USAGE.md index 51b93774..cba49ed4 100644 --- a/USAGE.md +++ b/USAGE.md @@ -71,18 +71,34 @@ using (var archive = ZipArchive.Create()) memoryStream.Position = 0; ``` -### Extract all files from a Rar file to a directory using RarArchive +### Extract all files from a rar file to a directory using RarArchive + +Note: Extracting a solid rar or 7z file needs to be done in sequential order to get acceptable decompression speed. +It is explicitly recommended to use `ExtractAllEntries` when extracting an entire `IArchive` instead of iterating over all its `Entries`. +Alternatively, use `IArchive.WriteToDirectory`. + +```C# +using (var archive = RarArchive.Open("Test.rar")) +{ + using (var reader = archive.ExtractAllEntries()) + { + reader.WriteAllToDirectory(@"D:\temp", new ExtractionOptions() + { + ExtractFullPath = true, + Overwrite = true + }); + } +} +``` + +### Iterate over all files from a Rar file using RarArchive ```C# using (var archive = RarArchive.Open("Test.rar")) { foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { - entry.WriteToDirectory("D:\\temp", new ExtractionOptions() - { - ExtractFullPath = true, - Overwrite = true - }); + Console.WriteLine($"{entry.Key}: {entry.Size} bytes"); } } ```