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
You need to change the target framework of the current project from .Net 4 to .Net 4.5.
In my case I needed to manually delete all dll references that started with System.IO.Compression and then add one by one the needed ones (System.IO.Compression.FileSystem, etc.) even though I only wrote a single using statement
using System.IO.Compression;
I hope this helps someone
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.
New features in .NET 4.5
Zip compression improvements to reduce the size of a compressed file. See the System.IO.Compression namespace.
Add System.IO.Compression assembly as reference to your project. You may also want to reference System.IO.Compression.FileSystem assembly to access three extension methods (from the ZipFileExtensions class) for the ZipArchive class: CreateEntryFromFile, CreateEntryFromFile, and ExtractToDirectory. These extension methods enable you to compress and decompress the contents of the entry to a file.
Sample
const string zipFilePath = @"C:\apps\Sample Pictures.zip";
using (FileStream zipFileToOpen = new FileStream(zipFilePath, FileMode.Open))
using (ZipArchive archive = new ZipArchive(zipFileToOpen, ZipArchiveMode.Read)) {
foreach (var zipArchiveEntry in archive.Entries)
Console.WriteLine(
"FullName of the Zip Archive Entry: {0}", zipArchiveEntry.FullName
);
}
References:
http://msdn.microsoft.com/en-us/library/ms171868.aspx
http://www.tugberkugurlu.com/archive/net-4-5-to-support-zip-file-manipulation-out-of-the-box
You also need to reference the System.IO.Compression.FileSystem.dll assembly.
For Windows Phone 8.1, use NuGet to add the Microsoft Compression package to your project and reference it.
If you had an older WP8 project you may have been using a different package that would create conflicts with the System.IO.Compression dll that is part of the .NET 4.5 that comes with WP8.1. You need to get rid of that and use Microsoft Compression which works harmoniously with .NET 4.5. That's how I got here!