View Archive Entries
When extracting archives, developers sometimes want to do a quick inspection to confirm whether an entry exists within the archive, as extracting an archive can be costly at times. IronZIP lets you view the archive entries within the archive without extracting them first, saving you time and allowing you to inspect and verify files quickly before extracting them.
Within this example, we'll quickly go through an example of utilizing the Entry class within IronZipArchive to obtain the list of entries within the archive and print out the names of the entries for inspection.
View Archvie Entries with C#
- using IronZip
- using (var archive = new IronZipArchive("existing.zip"))
- List
entries = archive.Entries(); - foreach (Entry entry in entries)
- Console.WriteLine(entry.Name);
Importing Existing Archive
We first import the namespace IronZip. Afterwards, we initialize a new IronZipArchive
with the path to the ZIP Archive as the parameter to load the archive.
Viewing The Contents of the Archive
After importing the ZIP archive, we can utilize the class properties of IronZipArchive to obtain the list of entries within the archive. The Entries property within the IronZipArchive returns a of Entry within the archive.
Entry Property
The Entry property contains several properties such as the name, size, version, and other properties such as comments and the encryption method used to create that entry. In this example, we utilize a for loop to loop over the number of entries within the list to print out all the names of the entries within the archive, showcasing the versatility of looking through the entries without extracting them. For a complete list of properities available for the class Entry, please refer here.
Discover how to Create, Read, and Extract ZIP Files with our Detailed Tutorial!