Compressing? Why not?
In this recipe, we will be looking at file compression capabilities supported on .NET Framework and how to use them in a .NET Standard 2.0 library. File compression classes are supported inside the System.IO.Compression
namespace. Classes inside this namespace are used to compress the file as well as decompress it. They are also used to read content inside a compressed file. Let's have a look and create a .NET Standard 2.0 library that compresses and decompresses a file.
Getting ready
Make sure you have the latest version of Visual Studio 2017 up and running. As mentioned previously, we will be using classes inside System.IO.Compression
. Mainly, we will be looking at the ZipFile
class. Let's get going and build our library that compresses and decompresses a file.
How to do it...
- Open Visual Studio 2017.
- Click
File
|New
|Project
to create a project. - In the
New Project
dialog box, expand theOther Project Types
node in the left-hand pane, and selectVisual Studio Solutions...