
When working with ZIP files, you may frequently encounter scenarios where multiple ZIP archives are nested within a parent ZIP archive. To access the contents of these nested archives, you’ll first need to extract the parent ZIP and then handle each nested archive individually. In this tutorial, we will guide you through how to efficiently extract nested ZIP archives in C# .NET without the need for complex code.
שולחן התוכן
שימוש ב- .NET API עבור Nested ZIP Archive Extraction
To perform the extraction of nested ZIP archives, we will utilize the תגית: ZIP for .NET library. This powerful API is specifically designed for archiving operations within .NET applications, enabling you to create and manipulate various archive formats with ease. You can choose to הורד את DLL של API or install it directly using נוגט with the following command:
PM> Install-Package Aspose.Zip
הדרכה שלב אחר צעד כדי להסיר ארכיון ZIP Nested
עבור ההפגנה שלנו, הכינו קובץ ZIP המכיל שלושה כניסות, כולל קבצי ZIP נטועים.

Nested ZIP Archives
אנו נוציא את כל ארכיון ZIP נטועים ונשמור את התוכן שלה לתוך תיקיות נפרדות.הנה צעדים לבצע עיבוד קובץ ZIP נטוע ב .NET:
- Create a FileStream: Load the parent ZIP file using a FileStream object.
- Load the ZIP File: Utilize the ארכיון class to load the ZIP file.
- Iterate through Archive Entries: Loop through each ארכיון in the ארכיון - כניסות collection.
- Filter Nested ZIP Archives: זיהה את ארכיוני ZIP באוסף ולכל אחד מהארכיונים הללו, עשה את הדברים הבאים:- Create a MemoryStream: Instantiate a זיכרון and copy the archive entry into it using the ArchiveEntry.Open().CopyTo( זרם) method.
- Load the Nested Archive: Create an instance of the ארכיון class to load the nested archive from the MemoryStream.
- Extract to Directory: Finally, extract the nested archive’s contents to a specified folder using the Archive.ExtractToDirectory(String) method.
הנה דגימה של קוד המראה כיצד להסיר את קבצי ZIP נטועים ב- C# .NET:
תמונת המסך הבאה מציגה את התוכן שנלקח מהארכיון ה-ZIP:

Unzipped Nested Archives
קבלת רישיון API חינם
You can obtain רישיון זמני חינם for Aspose.ZIP for .NET, allowing you to use the library without any evaluation limitations.
מסקנה
In this article, you have learned the best way to unzip nested ZIP files in C#. The step-by-step guide and code sample provided illustrate how to efficiently handle nested ZIP archives using the .NET framework. For further exploration of features, feel free to visit the ASPOSE.ZIP מסמכים or ask questions on our פורום.
על-ידי עמידה בהוראה זו **C# ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה ניסטה
עם התבוננות זו, אתה יכול בביטחון להתמודד עם האתגרים של ארכיוני ZIP Unzip ב- C#** ולאופטימיזציה של היישומים שלך עבור .NET Framework Unzip Nested ZIP עם מבנה תיעוד ו C# Unzip Nested ZIP קבצים שמירה על מבנה תיקיה.