開始使用 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 專案類型支援:
- 網頁 (Blazor 與 WebForms)
- 移動裝置(Xamarin & MAUI)
- 桌面(WPF 和 MAUI)
- 控制台(應用程式和函式庫)
安裝
IronZIP Library
安裝 IronZIP 既快速又容易,請按照以下方式安裝套件:
Install-Package IronZip
或者,直接從官方 IronZIP NuGet 網站下載。
安裝完成後,您可以開始在您的 C# 程式碼頂部添加 using IronZip;
。
套用授權金鑰
接著,通過將許可證密鑵指派給 License 類別的 LicenseKey 屬性,來為 IronZIP 應用有效的許可證或試用密鑵。 在import語句之後,使用任何IronZIP方法之前,請加入以下代碼:
: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"
程式碼範例
建立存檔範例
使用 '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
解壓縮檔案到文件夾
使用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")
將文件添加到現有的存檔
將 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
授權與支持可用
IronZIP 是一個收費的函式庫,但也提供免費試用許可證,在此獲取。
有關 Iron Software 的更多資訊,請訪問我們的網站:https://ironsoftware.com/
如需更多支持和查詢,請詢問我們的團隊。
來自 Iron Software 的支援
如需一般支援和技術查詢,請透過以下電子郵件與我們聯絡:support@ironsoftware.com