Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZipPackage Class vs Zipfile class

Tags:

c#

.net

zip

I feel confused with these two classes, both of them seem used to create or extract zip files? Can anyone explain the difference?

like image 826
James Avatar asked Oct 15 '12 05:10

James


People also ask

How does ZipArchive work?

Extension MethodsArchives a file by compressing it and adding it to the zip archive. Archives a file by compressing it using the specified compression level and adding it to the zip archive. Extracts all the files in the zip archive to a directory on the file system.

What is ZIP archive in C#?

Add Files or Folders to ZIP Archives Programmatically in C# April 22, 2020 · 5 min · Usman Aziz. The ZIP archives are used to compress and keep one or more files or folders into a single container. A ZIP archive encapsulates the files and folders as well as holds their metadata information.

How to Create Zip file in. net Core?

The ZipFile class has a CreateFromDirectory method that takes a target directory and a destination path for the resulting zip file. using System; using System.IO; using System. IO. Compression; // using a target directory // ZipFile will create // the zip file on disk ZipFile.


1 Answers

ZipPackage Class - Implements a derived subclass of the abstract Package base class—the ZipPackage class uses a ZIP archive as the container store. This class cannot be inherited.

Zipfile Class - Provides static methods for creating, extracting, and opening zip archives.

refer these links to get exact differences http://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx

http://msdn.microsoft.com/en-us/library/system.io.compression.zipfile.aspx

ZipPackage Class is used to handle packages, which uses the zip format for storage, but has special meta files included in the zip. A package is a zip, but all zip files aren't packages. You can only open a package using the Package class, not any zip file.

when you want just only the zip file I would prefer using zipFile class until I want my zip to be a package.

If you only want to zip your file and extract it use zipClass instead

like image 166
Ajeet Pratap Maurya Avatar answered Oct 13 '22 18:10

Ajeet Pratap Maurya