IronZIPを使い始める
IronZIP: .NETのためのオールインワンアーカイブライブラリ
IronZIPは、Iron Softwareによって開発されたアーカイブ圧縮および解凍ライブラリです。 広く使用されているZIP形式に加えて、TAR、GZIP、BZIP2形式も扱うことができます。
C#アーカイブ圧縮および解凍ライブラリ
- ファイル圧縮および解凍のためのC#ライブラリをダウンロード
- ZIP、TAR、GZIP、およびBZIP2フォーマットを扱う
- 圧縮レベルは0から9までカスタマイズ可能
- 圧縮されたアーカイブからコンテンツを抽出する
- 既存のZIPアーカイブにファイルを追加し、新しいZIPファイルを生成する
互換性
IronZIPは、以下のプラットフォームとのクロスプラットフォーム対応互換性があります:
.NETバージョンサポート:
- C#、VB.NET、F#
- .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"コード例
アーカイブ作成の例
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フォルダにアーカイブを解凍
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既存のアーカイブにファイルを追加
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ライセンスとサポートの提供
IronZIPは有料ライブラリですが、無料のトライアルライセンスもこちらで入手可能です。
Iron Softwareについての詳しい情報は、弊社のウェブサイトをご覧ください: https://ironsoftware.com/ サポートやお問い合わせに関しては、私たちのチームにお尋ねください。
Iron Software からのサポート
一般的なサポートや技術のお問い合わせは、次のメールアドレスまでご連絡ください:support@ironsoftware.com





