使用 IRONZIP 如何在 C# .NET Core 中創建 Zip 文件 Curtis Chau 更新日期:7月 28, 2025 Download IronZIP NuGet 下載 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article The name of the file format created by Phil Katz and first made popular by PKZIP is where the term "ZIP" originates. It is now a commonly used and well-known file compression standard for a variety of software programs and operating systems. To create, extract, or work with ZIP files, users can use a variety of software tools, operating system built-in functions, or command-line interfaces. This allows for effective file management and compression. A common archival file format and file compression tool for packing and compressing one or more files and directories into a single file is ZIP. Frequently, the ".zip" file extension serves as a clue. In this article, we will create a zip file using C# .NET Core. How to Create ZIP Files C# using .NET Core Launch a fresh ASP.NET Core project. To the generated project, install the IronZIP library. Using the IronArchive class, instantiate a blank ZIP file. To add files to the empty ZIP file, use the Add method. You may use the FromFile method to open an existing ZIP file. IronZIP Library The .NET library IronZIP, developed by Iron Software, simplifies the handling and management of ZIP files in .NET applications. It provides programmers with capabilities and tools to enable them to work with ZIP archives in several ways. These include creating, removing, compressing data, opening, decrypting, and editing the files and folders contained within ZIP files. Features of IronZIP ZIP File Creation: The ability for .NET applications to create fresh ZIP archives from the beginning. File Manipulation: Programmers can add, remove, update, and perform other operations on files and folders included in ZIP packages. Performance Optimization: Aims to maximize performance so that large ZIP files or datasets may be handled more efficiently by .NET programs. Extraction and Decompression: The ability to extract content and delete files and directories from pre-existing ZIP packages. Compression: Offers methods to reduce the size of files and folders into ZIP archives for storage or transportation. Password Protection and Encryption: This feature allows you to encrypt ZIP files and apply password protection to secure the contents of ZIP archives. Compatibility: Designed to work in a range of .NET environments and compatible with several framework versions. IronZIP may be a helpful tool for developers to manage ZIP files for their apps. It offers a range of functions, both simple and versatile, for interacting with ZIP archives programmatically within the .NET framework. Since software libraries are changed and improved over time, consult the official documentation, release notes, or the IronZIP website for the most up-to-date information on features, capabilities, compatibility, and any new functionality introduced in subsequent versions. To know more check here. Creating a New Project in Visual Studio Select File from the File menu after launching the Visual Studio program. After choosing "new project," choose ".NET Core console application." Enter the project name in the designated text field after choosing the file location. Next, as seen in the sample below, click the Create button and choose the required .NET Framework. The Visual Studio project will then construct its structure based on the selected application after that. If you want to create or execute the application via the console, Windows, or web application, you may add code by gaining access to the Program.cs file. After that, the code may be tested and the library added. 3.1 Using Visual Studio You may install packages directly into your solution using the Visual Studio software's NuGet Package Manager functionality. You may use the snapshot below to access the NuGet Package Manager. It provides a search box that pulls up a NuGet website package list. The screenshot below shows us where to look for the phrase "IronZip" in the package manager. In the image above, a list of pertinent search terms is displayed. Selecting the required option is required to install the solution package. 3.2 Using the Visual Studio Command-Line To view the Package Manager Console, select Tools > NuGet Package Manager in Visual Studio. Add the following line to the terminal tab of the package manager: Install-Package IronZip The package may now be used after downloading and installing it into the active project. 3.3 Direct download from the NuGet website The NuGet package may be downloaded straight from the website by using the third method. To access the Link, navigate there. From the menu on the right, choose the download package option. When the package has finished downloading, double-click it. It will install itself when it wants to. Start utilizing the solution in the project after loading it again. 3.4 Direct download from the IronZIP website To download the latest recent bundle straight away from the website, click this link. To include the package in the project, download it and adhere to the given guidelines. From the solution window, choose the project by doing a right-click. After it has been downloaded, pick the reference and look through its location. Once the reference has been added, click OK. Create a Zip file using IronZIP To use IronZIP to produce a ZIP archive file in C#, you must add files or directories to an archive before saving it. An example of using IronZIP to produce a ZIP file can be found below. using IronZip; class Program { static void Main() { // Create an instance of IronZipArchive which provides methods to add files // and save the archive using (var archive = new IronZipArchive()) { // Add files to the archive by providing the path archive.Add("1.png"); archive.Add("2.png"); // Save the archive as a ZIP file archive.SaveAs("new.zip"); } } } using IronZip; class Program { static void Main() { // Create an instance of IronZipArchive which provides methods to add files // and save the archive using (var archive = new IronZipArchive()) { // Add files to the archive by providing the path archive.Add("1.png"); archive.Add("2.png"); // Save the archive as a ZIP file archive.SaveAs("new.zip"); } } } Imports IronZip Friend Class Program Shared Sub Main() ' Create an instance of IronZipArchive which provides methods to add files ' and save the archive Using archive = New IronZipArchive() ' Add files to the archive by providing the path archive.Add("1.png") archive.Add("2.png") ' Save the archive as a ZIP file archive.SaveAs("new.zip") End Using End Sub End Class $vbLabelText $csharpLabel In the code above, we first create an object for IronZipArchive which will allow us to use the Add method to add files to the archive. You can pass file paths as parameters to this method to include files in the ZIP. We then use the SaveAs method to save the new ZIP file to the file system in the specified directory. It consolidates all the added files into a single ZIP file. To read more about IronZIP click here. Conclusion IronZIP is a .NET library created especially for managing ZIP files in C# applications. It allows developers to manage the compression, extraction, and modification of ZIP files. IronZIP uses a clear API to simplify complex processes and make file operations easier, such as extracting specific files, extracting files in bulk, adding entries, and altering existing archives. Developers may enhance file management capabilities in C# projects without having to start from scratch by using this package. It fits in with ease. Because of its flexibility, files may be added, modified, and removed from ZIP files dynamically to meet the needs of different applications. IronZIP's robust exception-handling tools provide a consistent workflow and facilitate error correction in scenarios such as missing or damaged ZIP files. While my memory may not match the latest updates, IronZIP provided a reliable option for handling ZIP files in .NET settings in the past. IronZIP offers a free trial, with pricing starting from $799. We may go here to learn more about which licensing version would work best for you and your team. Check out this link for the Iron software product. 常見問題解答 如何在 C# .NET Core 中建立 ZIP 檔案? 您可以使用 IronZIP 在 C# .NET Core 中建立 ZIP 檔案。首先在 Visual Studio 中設置新的 ASP.NET Core 專案,然後使用 NuGet 封裝管理器安裝 IronZIP。使用 IronArchive 類例化一個新的 ZIP 檔案,並使用 Add 方法添加檔案。 IronZIP 提供哪些功能來管理 ZIP 檔案? IronZIP 提供創建、刪除、壓縮、打開、解密和編輯 ZIP 檔案中的檔案和資料夾等功能。它支援提取、解壓密、密碼保護和加密,是.NET 應用程式檔案管理的全面工具。 如何在 Visual Studio 專案中安裝 IronZIP? 要在 Visual Studio 專案中安裝 IronZIP,使用 NuGet 封裝管理器。您還可以使用封裝管理器控制台命令 Install-Package IronZip 將其添加到專案中。 我可以使用 IronZIP 為 ZIP 檔案進行密碼保護嗎? 是的,IronZIP 允許您使用密碼保護和加密來保護您的 ZIP 檔案。這確保了您的 ZIP 資料夾內容受到保護,只有授權用戶才能訪問。 使用 IronZIP 進行 C# 專案檔案管理有哪些好處? IronZIP 提供簡單易用的方法來管理 ZIP 檔案的壓縮、提取及修改。它能無縫整合到 C# 專案中,並透過強大的功能增強檔案管理能力。 IronZIP 提供免費試用版嗎? 是的,IronZIP 提供免費試用版。您可以探索其功能,看看它如何增強您的檔案管理工作。授權選項從輕量版許可開始,詳細資訊請參閱 Iron Software 網站。 如何在 Visual Studio 中開始一個新專案來使用 IronZIP? 要在 Visual Studio 中使用 IronZIP 開始一個新專案,選擇 'File' > 'New Project',選擇 '.NET Core console application',然後選擇所需的 .NET 框架來設置專案。 如何使用 IronZIP 添加檔案到 ZIP 歸檔? 要使用 IronZIP 添加檔案到 ZIP 歸檔,建立一個 IronZipArchive 物件並使用 Add 方法包括檔案。最後,使用 SaveAs 方法將歸檔保存為 ZIP 檔案。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 相關文章 更新日期 6月 22, 2025 如何在 C# 中將 Zip 存檔提取到目錄 ZIP 文件是一種將多個文件和目錄打包成單個存檔的方便方式。 閱讀更多 更新日期 7月 28, 2025 如何在 C# 中使用密碼壓縮文件 在本文中,我們將探討如何使用 C# 和 IronZIP 庫創建受密碼保護的 ZIP 文件 閱讀更多 更新日期 7月 28, 2025 如何在 C# 中將文件解壓到目錄 無論你在開發Windows 應用程序還是 .NET 項目,了解解壓文件的過程都是非常有價值的 閱讀更多 如何在 C# 中打開 Zip 文件如何在 C# 中解壓縮 Zip 文件