Getting Started with IronZIP

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronZIP: .NETのためのオールインワンアーカイブライブラリ

IronZIPは、Iron Softwareによって開発されたアーカイブ圧縮および解凍ライブラリです。 広く使用されているZIP形式に加えて、TAR、GZIP、BZIP2形式も扱うことができます。

C#アーカイブ圧縮および解凍ライブラリ

  1. ファイル圧縮および解凍のためのC#ライブラリをダウンロード
  2. ZIP、TAR、GZIP、およびBZIP2フォーマットを扱う
  3. 圧縮レベルは0から9までカスタマイズ可能
  4. 圧縮されたアーカイブからコンテンツを抽出する
  5. 既存のZIPアーカイブにファイルを追加し、新しいZIPファイルを生成する

互換性

IronZIPは、以下のプラットフォームとのクロスプラットフォーム対応互換性があります:

.NETバージョンサポート:

  • C#VB.NETF#
  • .NET 7, 6、5、およびCore 3.1+
  • .NET Standard (2.0+)
  • .NET Framework (4.6.2+)

オペレーティングシステムと環境のサポート:

  • Windows (10+, Server 2016+)
  • Linux (Ubuntu, Debian, CentOSなど)
  • macOS (10+)
  • iOS (12+)
  • Android API 21+ (v5 “Lollipop”)
  • Docker (Windows、Linux、Azure)
  • Azure (VPS、WebApp、Function)
  • AWS (EC2、Lambda)

.NETプロジェクトタイプサポート:

  • Web (Blazor & WebForms)
  • モバイル (Xamarin & MAUI)
  • デスクトップ (WPF & MAUI)
  • コンソール (App & ライブラリ)

インストール

IronZIPライブラリ

IronZIPパッケージをインストールするには、ターミナルまたはパッケージマネージャコンソールで以下のコマンドを使用してください:

Install-Package IronZip

または、公式IronZIP NuGetウェブサイトから直接ダウンロードしてください。

インストールが完了したら、C#コードの先頭にusing IronZip;を追加して使い始めることができます。

ライセンスキーの適用

次に、ライセンスキーをLicenseクラスのLicenseKeyプロパティに割り当てることで、IronZIPに有効なライセンスまたはトライアルキーを適用します。 import文の直後、IronZIPメソッドを使用する前に次のコードを含めてください:

using IronZip;

// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
using IronZip;

// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
Imports IronZip

' Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY"
$vbLabelText   $csharpLabel

コード例

アーカイブ作成の例

using文を使用してZIPファイルを作成します。 usingブロック内で、AddArchiveEntryメソッドを使用してファイルをZIPファイルにインポートし、SaveAsメソッドでZIPファイルをエクスポートします。

using IronZip;
using System.IO;

class Program
{
    static void Main()
    {
        // Create a new ZIP file
        using (var archive = new ZipArchive())
        {
            // Add a file to the archive
            archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"));

            // Save the ZIP archive
            archive.SaveAs("archive.zip");
        }
    }
}
using IronZip;
using System.IO;

class Program
{
    static void Main()
    {
        // Create a new ZIP file
        using (var archive = new ZipArchive())
        {
            // Add a file to the archive
            archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"));

            // Save the ZIP archive
            archive.SaveAs("archive.zip");
        }
    }
}
Imports IronZip
Imports System.IO

Friend Class Program
	Shared Sub Main()
		' Create a new ZIP file
		Using archive = New ZipArchive()
			' Add a file to the archive
			archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"))

			' Save the ZIP archive
			archive.SaveAs("archive.zip")
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

フォルダにアーカイブを解凍

ExtractArchiveToDirectoryメソッドを使用してZIPファイルからコンテンツを抽出します。 ターゲットのZIPファイルのパスと抽出ディレクトリを指定します。

using IronZip;

class Program
{
    static void Main()
    {
        // path to the ZIP file and extraction directory
        string zipPath = "archive.zip";
        string extractPath = "extracted/";

        // Extract all files in the ZIP archive to the specified directory
        using (var archive = new ZipArchive(zipPath))
        {
            archive.ExtractArchiveToDirectory(extractPath);
        }
    }
}
using IronZip;

class Program
{
    static void Main()
    {
        // path to the ZIP file and extraction directory
        string zipPath = "archive.zip";
        string extractPath = "extracted/";

        // Extract all files in the ZIP archive to the specified directory
        using (var archive = new ZipArchive(zipPath))
        {
            archive.ExtractArchiveToDirectory(extractPath);
        }
    }
}
Imports IronZip

Friend Class Program
	Shared Sub Main()
		' path to the ZIP file and extraction directory
		Dim zipPath As String = "archive.zip"
		Dim extractPath As String = "extracted/"

		' Extract all files in the ZIP archive to the specified directory
		Using archive = New ZipArchive(zipPath)
			archive.ExtractArchiveToDirectory(extractPath)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

既存のアーカイブにファイルを追加

ZIPファイルのパスをコンストラクターに渡すことで、ZIPファイルを開きます。AddArchiveEntryメソッドを利用してオープンしたZIPにファイルを追加し、SaveAsメソッドでエクスポートします。

using IronZip;
using System.IO;

class Program
{
    static void Main()
    {
        // Open an existing ZIP file
        using (var archive = new ZipArchive("archive.zip"))
        {
            // Add more files to the archive
            archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"));

            // Save updates to the ZIP archive
            archive.SaveAs("archive.zip");
        }
    }
}
using IronZip;
using System.IO;

class Program
{
    static void Main()
    {
        // Open an existing ZIP file
        using (var archive = new ZipArchive("archive.zip"))
        {
            // Add more files to the archive
            archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"));

            // Save updates to the ZIP archive
            archive.SaveAs("archive.zip");
        }
    }
}
Imports IronZip
Imports System.IO

Friend Class Program
	Shared Sub Main()
		' Open an existing ZIP file
		Using archive = New ZipArchive("archive.zip")
			' Add more files to the archive
			archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"))

			' Save updates to the ZIP archive
			archive.SaveAs("archive.zip")
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

ライセンスとサポートの提供

IronZIPは有料ライブラリですが、無料のトライアルライセンスもこちらで入手可能です。

Iron Softwareについての詳しい情報は、弊社のウェブサイトをご覧ください: https://ironsoftware.com/ サポートやお問い合わせに関しては、私たちのチームにお尋ねください

Iron Software からのサポート

一般的なサポートや技術のお問い合わせは、次のメールアドレスまでご連絡ください:support@ironsoftware.com

Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はいいですか?
Nuget ダウンロード 16,000 | バージョン: 2025.11 ただ今リリースされました