Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installed .Net 4.5 but can't use ZipFile class in Visual C#

I'm kind of a newbie to Visual Studio programming.

I recently upgraded .Net 4.0 to 4.5 in order to use the ZipFile class under System.IO.Compression, but after the installation completed, Visual Studio (I'm using 2012) still cannot recognize ZipFile as a class name.

I've made sure that .Net 4.5 appears in Control Panel programs list and my C# solution sets .Net Framework 4 as the target framework.

Could someone help me figure this out?

like image 799
wuxilixi Avatar asked Jan 08 '13 15:01

wuxilixi


People also ask

How do I create a zip file in dotnet core?

string startPath = @"c:\example\start"; string zipPath = @"c:\example\result. zip"; string extractPath = @"c:\example\extract"; ZipFile. CreateFromDirectory(startPath, zipPath); ZipFile.


2 Answers

See ZipFile Class on MSDN. It shows the required framework version is 4.5. Once the framework version is fixed check you have added a reference to the System.IO.Compression.FileSystem.dll assembly and added a using System.IO.Compression directive to your class.

like image 192
Daniel Kelley Avatar answered Sep 24 '22 03:09

Daniel Kelley


You also need to reference the System.IO.Compression.FileSystem.dll assembly.

like image 28
platon Avatar answered Sep 21 '22 03:09

platon