Fragile 1.0.0.6

Suggested Alternatives

Fragile 1.0.0.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package Fragile --version 1.0.0.6
                    
NuGet\Install-Package Fragile -Version 1.0.0.6
                    
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="Fragile" Version="1.0.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fragile" Version="1.0.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Fragile" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Fragile --version 1.0.0.6
                    
#r "nuget: Fragile, 1.0.0.6"
                    
#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.
#addin nuget:?package=Fragile&version=1.0.0.6
                    
Install Fragile as a Cake Addin
#tool nuget:?package=Fragile&version=1.0.0.6
                    
Install Fragile as a Cake Tool

Fragile

Fragile is a comprehensive archiving library for .NET, featuring file compression, encryption, error correction, and integrity verification. It provides advanced capabilities for creating and managing secure, reliable archives in .NET applications.

Features

  • Multiple Compression Algorithms: Store, Brotli, Deflate, LZMA, LZ4, ZStd, and BZip2
  • Strong Encryption: AES-256, ChaCha20, and Twofish encryption
  • Error Correction: Reed-Solomon based error correction for file recovery
  • Integrity Verification: CRC32 and other hashing algorithms for data integrity
  • Parallel Processing: Optimized performance through parallel operations
  • Split Archives: Split large archives into manageable parts
  • Metadata Support: Store and retrieve custom metadata for archives and files
  • Multi-Platform Support: Works on .NET Framework 4.8, .NET 6-10, and .NET Standard 2.0/2.1

Installation

dotnet add package Fragile

Or through the NuGet Package Manager:

Install-Package Fragile

Basic Usage

Creating an Archive

using Fragile.Core;
using Fragile.Models;

// Create a new archive
using (FragileArchive archive = new FragileArchive("example.frgl", FragileArchiveMode.Create))
{
    // Add files and directories
    archive.AddFile("document.docx");
    archive.AddDirectory("images", recursive: true);
    
    // Save the archive
    archive.Save();
}

Extracting an Archive

// Open an existing archive
using (FragileArchive archive = new FragileArchive("example.frgl", FragileArchiveMode.Read))
{
    // Extract all files
    archive.ExtractAll("output_directory");
    
    // Or extract specific files
    archive.Extract("document.docx", "output_directory/document.docx");
}

Advanced Features

Compression Options

var options = new FragileOptions
{
    CompressionAlgorithm = CompressionAlgorithm.LZMA,
    CompressionLevel = CompressionLevel.Maximum
};

using (FragileArchive archive = new FragileArchive("compressed.frgl", FragileArchiveMode.Create, options))
{
    // Add and save files with high compression
    archive.AddFile("large_file.bin");
    archive.Save();
}

Encryption

var options = new FragileOptions
{
    EnableEncryption = true,
    EncryptionMethod = EncryptionMethod.AES256,
    Password = "your-secure-password"
};

using (FragileArchive archive = new FragileArchive("secure.frgl", FragileArchiveMode.Create, options))
{
    archive.AddFile("confidential.pdf");
    archive.Save();
}

Error Correction

var options = new FragileOptions
{
    EnableErrorCorrection = true,
    ErrorCorrectionLevel = 10 // Percentage of data redundancy
};

using (FragileArchive archive = new FragileArchive("recoverable.frgl", FragileArchiveMode.Create, options))
{
    archive.AddFile("important.db");
    archive.Save();
}

Splitting Large Archives

var options = new FragileOptions
{
    SplitSize = 100 * 1024 * 1024 // 100 MB parts
};

using (FragileArchive archive = new FragileArchive("large.frgl", FragileArchiveMode.Create, options))
{
    archive.AddDirectory("huge_directory", recursive: true);
    archive.Save();
    
    // Split the archive into parts
    FragileArchivePartCollection parts = await archive.SplitAsync("output");
    Console.WriteLine($"Archive split into {parts.Count} parts");
}

Working with Metadata

using (FragileArchive archive = new FragileArchive("metadata.frgl", FragileArchiveMode.Create))
{
    // Set archive-level metadata
    archive.Metadata.Author = "Your Name";
    archive.Metadata.CreationDate = DateTime.UtcNow;
    archive.Metadata.Description = "Project Backup";
    
    // Add files with metadata
    var entry = archive.AddFile("project.zip");
    
    // Set entry-specific metadata
    var entryMetadata = new EntryMetadata
    {
        Title = "Project Source Code",
        Keywords = new[] { "source", "backup", "project" },
        CustomProperties = new Dictionary<string, string>
        {
            { "Version", "1.0.0" },
            { "Department", "Development" }
        }
    };
    
    archive.SetEntryMetadata(entry.Path, entryMetadata);
    archive.Save();
}

Async API Support

// Create archive asynchronously
FragileArchive archive = await FragileArchive.CreateAsync("async.frgl");

// Add files
await archive.AddFileAsync("document.docx");

// Extract files asynchronously
await archive.ExtractAllAsync("output_directory");

// Save asynchronously
await archive.SaveAsync();

Split Archive Creation

Fragile has the ability to automatically split large files into multiple parts when archiving. You can do this in two ways:

1. Splitting an existing archive:

// Split an existing archive into 100 MB parts
FragileArchivePartCollection parts = await FragileUtility.SplitArchiveAsync("C:/Data/large-archive.frgl");

// List the parts
foreach (var part in parts)
{
    Console.WriteLine($"Part {part.PartIndex}/{part.TotalParts}: {part.Path} ({part.Size} bytes)");
}

2. Creating a directly split archive:

// Split the archive directly during creation (each part will be 50 MB)
FragileOptions options = new FragileOptions
{
    SplitSize = 50 * 1024 * 1024, // 50 MB parts
    CompressionAlgorithm = CompressionAlgorithm.Deflate,
    CompressionLevel = CompressionLevel.Fastest
};

// Archive a file or folder and directly split it into parts
FragileArchivePartCollection parts = await FragileUtility.CreateSplitArchiveAsync(
    "C:/Data/LargeFolder", 
    "C:/Backup/archive.frgl", 
    true,
    options);

Console.WriteLine($"Archive split into {parts.Count} parts.");

Combining Parts:

// Combine all parts by specifying the first part
await FragileUtility.CombinePartsAsync(
    "C:/Backup/archive.part001.frgl", 
    "C:/Restore/archive.frgl");
    
// For password-protected parts:
FragileOptions options = new FragileOptions 
{
    Password = "my-secure-password"
};

await FragileUtility.CombinePartsAsync(
    "C:/Backup/archive.part001.frgl", 
    "C:/Restore/archive.frgl",
    options);

License

This project is licensed under the terms of the LICENSE file included in the repository.

Documentation

For more information, visit the project website or check the GitHub repository.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.