FastZipEntry 1.0.0

dotnet add package FastZipEntry --version 1.0.0                
NuGet\Install-Package FastZipEntry -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FastZipEntry" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FastZipEntry --version 1.0.0                
#r "nuget: FastZipEntry, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FastZipEntry as a Cake Addin
#addin nuget:?package=FastZipEntry&version=1.0.0

// Install FastZipEntry as a Cake Tool
#tool nuget:?package=FastZipEntry&version=1.0.0                

FastZipEntry

.NET library designed to efficiently retrieve specific entries from a ZIP archive without extracting the entire archive or iterating through all entries. This library leverages modified code from Microsoft's System.IO.Compression.

Features

  • Efficiently locate and retrieve specific ZIP entries by name.
  • Avoid loading all entries into memory.
  • Supports custom encoding for entry names and comments.
  • Provides a straightforward API for accessing and decompressing ZIP entries.

Installation

You can install the FastZipEntry package via NuGet:

dotnet add package FastZipEntry

Usage

Creating an Instance

To use FastZipEntry, create an instance by passing a stream of the ZIP file and an optional encoding for entry names and comments.

using System.IO;
using System.Text;
using FastZipEntry;

// Example: Open a ZIP file and create a ZipEntryAccess instance
using FileStream zipFileStream = new FileStream("path/to/your.zip", FileMode.Open, FileAccess.Read);
ZipEntryAccess zipEntryAccess = new ZipEntryAccess(zipFileStream, Encoding.UTF8);

Retrieving an Entry

To retrieve a specific entry from the ZIP archive, use the RetrieveZipEntry method by providing the name of the entry and an optional StringComparison parameter.

// Example: Retrieve a specific entry from the ZIP file
string entryName = "desired_entry.txt";
ZipEntry? entry = zipEntryAccess.RetrieveZipEntry(entryName, StringComparison.OrdinalIgnoreCase);

if (entry != null)
{
    // Use the entry (e.g., decompress it)
    using Stream entryStream = entry.Open();
    using FileStream outputStream = new FileStream("path/to/extracted/desired_entry.txt", FileMode.Create, FileAccess.Write);
    entryStream.CopyTo(outputStream);
}
else
{
    Console.WriteLine("Entry not found.");
}

Decompressing an Entry

Once you have retrieved a ZipEntry, you can decompress it using the Open method, which returns a Stream for the entry's contents.

// Example: Decompress and read the content of the retrieved entry
using Stream entryStream = entry.Open();
using StreamReader reader = new StreamReader(entryStream);
string content = reader.ReadToEnd();
Console.WriteLine(content);

License This project is licensed under the MIT License. See the LICENSE file for more details.

Contributing Contributions are welcome! Please open an issue or submit a pull request for any changes or improvements.

Acknowledgments This library is based on modified code from the Microsoft System.IO.Compression repository.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 167 5/28/2024