can't add the System.IO.Compression.FileSystem namespace

Viewed 3480

I want to use ZipFile class but can't figure out how to add namespace properly.

ZipFile.CreateFromDirectory(startPath, zipPath);
ZipFile.ExtractToDirectory(zipPath, extractPath);

gives

ErrorCS0117 'ZipFile' does not contain a definition for 'CreateFromDirectory'

ErrorCS0117 'ZipFile' does not contain a definition for 'ExtractToDirectory'

I have added the

using System.IO;
using System.IO.Compression;
using System.IO.Compression.FileSystem;

which results in

Error CS0234 The type or namespace name 'FileSystem' does not exist in the namespace 'System.IO.Compression;

added the assembly references to

System.IO.Compression

Assembly System.IO.Compression
    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.IO.Compression.dll

System.IO.Compression.FileSystem

    Assembly System.IO.Compression.FileSystem
        C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.IO.Compression.FileSystem.dll

tried to install/uninstall packages with NuGet. Rebuild, even restart the PC.

Nothing seems to be working. The current version of .Net in VS is 4.7

2 Answers

Please add reference System.IO.Compression.FileSystem Screenshot for your reference. enter image description here

You need to add a reference to System.IO.Compression.FileSystem assembly from the Framework.

Related