Creating and extracting ZIP archives
One of the most basic things you can do is work with ZIP files. The .NET Framework does an excellent job at providing this functionality right out of the box. You might need to provide ZIP functionality in an application that needs to upload several files to a network share. Being able to ZIP several files and upload a single ZIP file makes more sense than having to upload several smaller files.
Getting ready
Perform the following steps:
- Create a console application and call it
FilesExample
:

- Right-click on the
References
node and selectAdd Reference...
from the context menu:

- In the
Reference Manager
, search for the wordcompression
. Add a reference toSystem.IO.Compression
andSystem.IO.Compression.FileSystem
to your project and click on theOK
button.
Note
At the time of writing, there was a System.IO.Compression
version 4.1.0.0 and System.IO.Compression
version 4.0.0.0 available from the Reference Manager
. The example I created just used version 4.1.0.0...