YGZipLib 1.0.23

There is a newer version of this package available.
See the version list below for details.
dotnet add package YGZipLib --version 1.0.23                
NuGet\Install-Package YGZipLib -Version 1.0.23                
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="YGZipLib" Version="1.0.23" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YGZipLib --version 1.0.23                
#r "nuget: YGZipLib, 1.0.23"                
#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 YGZipLib as a Cake Addin
#addin nuget:?package=YGZipLib&version=1.0.23

// Install YGZipLib as a Cake Tool
#tool nuget:?package=YGZipLib&version=1.0.23                

YGZipLib

YGZipLib is a compression/decompression library for ZIP archives.

Features

Compression/decompression processes are performed in multiprocessing
AES encryption support
Easy to use

Usage

  • Compression method
    using YGZipLib;

    public void Compress()
    {
        // // Instances should be Disposed.
         using(ZipArcClass zip = new ZipArcClass(@"R:\example.zip"))
         {
             // Compression Option Setting
             zip.EncryptionOption = ZipArcClass.ENCRYPTION_OPTION.AES256;
             zip.Password = "password";
             // single file compression
             zip.AddFilePath(@"R:\example_file.txt");
             // directory compression
             zip.AddDirectory(@"R:\example_dir");
             // Finish call
             zip.Finish();
         }
     }
  • Decompression Method
    using YGZipLib;
    using System.Collections.Generic;
    using System.IO;

    public void Decompress()
    {
        // Instances should be Disposed.
        using(UnZipArcClass unzip = new UnZipArcClass(@"R:\example.zip"))
        {
            // Set password if the file is encrypted.
            unzip.Password = "password";

            // --- Processed per file ---
            // Obtaining a list of files in a ZIP archive
            List<UnZipArcClass.CentralDirectoryInfo> dirList = unzip.GetFileList;
            // Loop and process
            dirList.FindAll(d => d.IsDirectory == false).ForEach(d => unzip.PutFile(d, Path.Combine(@"R:\uncompressdir", d.FileName)));

            // --- batch directory processing ---
            unzip.ExtractAllFiles(new DirectoryInfo(@"R:\uncompressdir"));
        }
    }
  • Output ZIP file as Stream by web service, etc.
    using YGZipLib;
    using System.IO;

    /// <summary>
    /// Example of sending a ZIP file via a web service, etc.
    /// </summary>
    /// <param name="resStream"></param>
    public async void SendZipFile (Stream resStream)
    {
        // Instances should be Disposed.
        using(ZipArcClass zip = new ZipArcClass(resStream))
        {
            await zip.AddFileStreamAsync("example1.dat", stream1);
            await zip.AddFileStreamAsync("/dir/example2.dat", stream2);
            await zip.FinishAsync();
        }
    }
  • Async
    // Example
    List<Task> taskList = new List<Task>();
    taskList.Add(zip.AddFilePathAsync(@"D:\example1.txt"));
    taskList.Add(zip.AddFilePathAsync(@"D:\example2.txt"));
    taskList.Add(zip.AddFilePathAsync(@"D:\example3.txt"));
    Task t = Task.WhenAll(taskList);
  • Other Settings

ZipArcClass

    // Processing multiplicity and working directory
    // ProcessorCount or 4, whichever is smaller. 0 is the default value.
    // For slow storage, process multiplexing should be lowered.
    // The working directory should be a fast device; if null is specified, it is automatically set from the environment.
    YGZipLib.ZipArcClass zip = new ZipArcClass(@"D:\zipfile.zip", 8, @"R:\temp");

    // Only archive without compression
    zip.CompressionOption = ZipArcClass.COMPRESSION_OPTION.NOT_COMPRESSED;

    // If you want the file to be uncompressed, specify the extension with a regular expression.
    zip.DontCompressExtRegExList.Add(new Regex("jpg", RegexOptions.IgnoreCase));
    zip.DontCompressExtRegExList.Add(new Regex("xls.*", RegexOptions.IgnoreCase));

    // Encryption Algorithms
    zip.EncryptionOption = ZipArcClass.ENCRYPTION_OPTION.TRADITIONAL;   // default
    zip.EncryptionOption = ZipArcClass.ENCRYPTION_OPTION.AES256;        // AES 256bit

    // Encoding of store file name and password.
    // The default is System.Globalization.CultureInfo.CurrentUICulture.TextInfo.ANSICodePage
    // See Note
    zip.ZipFileNameEncoding = System.Text.Encoding.GetEncoding("shift-jis");

Note on ZipFileNameEncoding
For non- NET Framework environments (e.g., .net Core, .net5 or later), only ascii and utf are available unless CodePagesEncodingProvider is registered.
Reference Site https://learn.microsoft.com/ja-jp/dotnet/api/system.text.codepagesencodingprovider
If CodePagesEncodingProvider is not registered and the OS language does not support Encoding, the file name is stored in UTF-8.

    // CodePagesEncodingProvider Registration
    // Register once at the start of the program
    Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

UnZipArcClass

    // Get list of stored files.
    List<YGZipLib.UnZipArcClass.CentralDirectoryInfo> dirList = unzip.GetFileList;

    // Processing multiplicity and working directory
    // See ZipArcClass
    YGZipLib.UnZipArcClass unzip = new UnZipArcClass(@"D:\zipfile.zip", 4, @"R:\temp");

    // TextEncodings of stored files.
    // See ZipArcClass
    unzip.ZipFileNameEncoding = System.Text.Encoding.GetEncoding("shift-jis");

Note

Finish should be called at the end when creating a ZIP archive.

License

"YGZipLib" is under MIT license

This library includes the work that is distributed in the Apache License 2.0.
The Deflate64 code included in YGZipLib is based on the following java source from Apache Commons Compress™.

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 was computed.  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. 
.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 net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  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.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.8.1

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • 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.25 641 3/16/2024
1.0.24 303 1/18/2024
1.0.23 143 1/16/2024
1.0.22 203 11/30/2023
1.0.19 260 6/16/2023
1.0.18 151 5/28/2023
1.0.17 384 5/18/2023
1.0.16 157 4/24/2023
1.0.13 212 4/10/2023
1.0.12 220 3/31/2023
1.0.11 221 3/29/2023