開始使用 IronZIP

IronZIP: 您的一站式.NET壓縮庫

IronZIP 是由 Iron Software 開發的壓縮和解壓縮庫。除了廣泛使用的 ZIP 格式外,它還可以處理 TAR、GZIP 和 BZIP2。

相容性

IronZIP 擁有跨平台支援相容性:

.NET 版本支援:

  • C#, VB.NET, F#
  • .NET 7, 6,5,以及 Core 3.1+
  • .NET Standard (2.0+)
  • .NET 框架 (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, 網頁應用, 函式)
  • AWS (EC2,Lambda)

.NET 專案類型支援:

  • 網站 (Blazor 和 WebForms)
  • 行動裝置 (Xamarin & MAUI)
  • 桌面 (WPF & MAUI)
  • 控制台 (應用程序及庫)

安裝

IronZIP Library

安裝 IronZIP 很快速且容易,請像這樣安裝套件:

Install-Package IronZip

或者,直接從 官方 IronZIP NuGet 網站一旦安裝完成,您可以在C#程式碼頂部添加 using IronZip; 來開始使用。

套用授權金鑰

接下來,通過將授權金鑰分配給License類的LicenseKey屬性,以此來套用有效的授權或試用金鑰至IronZIP。在使用任何IronZIP方法之前,請在import語句之後直接包含以下程式碼:

:path=/static-assets/zip/content-code-examples/get-started/get-started-license.cs
IronZip.License.LicenseKey = "IRONZIP.MYLICENSE.KEY.1EF01";
IronZip.License.LicenseKey = "IRONZIP.MYLICENSE.KEY.1EF01"
VB   C#

程式碼範例

建立檔案範例

使用 'using' 語句建立 ZIP 文件。在 using 區塊內,使用 AddArchiveEntry 方法將文件匯入 ZIP 文件中。最後,使用 SaveAs 方法匯出 ZIP 文件。

:path=/static-assets/zip/content-code-examples/get-started/get-started-1.cs
using IronZip;

// Create an empty ZIP
using (var archive = new IronZipArchive())
{
    // Add files to the ZIP
    archive.Add("./assets/image1.png");
    archive.Add("./assets/image2.png");

    // Export the ZIP file
    archive.SaveAs("output.zip");
}
Imports IronZip

' Create an empty ZIP
Using archive = New IronZipArchive()
	' Add files to the ZIP
	archive.Add("./assets/image1.png")
	archive.Add("./assets/image2.png")

	' Export the ZIP file
	archive.SaveAs("output.zip")
End Using
VB   C#

將壓縮檔解壓縮到資料夾

使用 ExtractArchiveToDirectory 方法解壓縮 ZIP 檔案中的內容。指定目標 ZIP 檔案的路徑和解壓縮目錄。

:path=/static-assets/zip/content-code-examples/get-started/get-started-2.cs
using IronZip;

// Extract ZIP
IronZipArchive.ExtractArchiveToDirectory("output.zip", "extracted");
Imports IronZip

' Extract ZIP
IronZipArchive.ExtractArchiveToDirectory("output.zip", "extracted")
VB   C#

向現有的存檔添加文件

將 ZIP 文件路徑傳遞給構造函數將打開 ZIP 文件。使用相同的 AddArchiveEntry 方法將文件添加到打開的 ZIP 並通過 SaveAs 方法導出。

:path=/static-assets/zip/content-code-examples/get-started/get-started-3.cs
using IronZip;

// Open existing ZIP
using (var archive = new IronZipArchive("existing.zip"))
{
    // Add files
    archive.Add("./assets/image3.png");
    archive.Add("./assets/image4.png");

    // Export the ZIP file
    archive.SaveAs("result.zip");
}
Imports IronZip

' Open existing ZIP
Using archive = New IronZipArchive("existing.zip")
	' Add files
	archive.Add("./assets/image3.png")
	archive.Add("./assets/image4.png")

	' Export the ZIP file
	archive.SaveAs("result.zip")
End Using
VB   C#

授權及支援可用性

IronZIP 是收費的庫,但是也提供免費試用授權 這裡了解更多有關 Iron Software 的資訊,請造訪我們的網站:https://ironsoftware.com/

如需更多支持和詢問,請 請詢問我們的團隊.

Iron Software 支援

如有一般支援及技術問題,請發送電子郵件至:support@ironsoftware.com