I feel confused with these two classes, both of them seem used to create or extract zip files? Can anyone explain the difference?
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With