Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@ 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"))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
using (var reader = archive.ExtractAllEntries())
{
entry.WriteToDirectory("D:\\temp", new ExtractionOptions()
reader.WriteAllToDirectory(@"D:\temp", new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
Expand All @@ -87,6 +91,18 @@ using (var archive = RarArchive.Open("Test.rar"))
}
```

### 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))
{
Console.WriteLine($"{entry.Key}: {entry.Size} bytes");
}
}
```

### Use ReaderFactory to autodetect archive type and Open the entry stream

```C#
Expand Down