Zip Archive Class in .NET 4.5

In .NET 4.5, the System.IO.Compression namespace contains the following new classes for compressing and decompressing the streams:

1- ZipArchive which represents a Zip archive.

2- ZipArchiveEntry which represents an entry in the zip archive.

The ExtractToDirectory and CreateFromDirectory methods of ZipArchive class can be used to handle the following most used scenarios:

Scenario 1 – Unzipping: Use ExtractToDirectory method to extract all the contents of a zip archive to the specified directory

Scenario 2 – Zipping: the contents: Use CreateFromDirectory to take the contents of the directory and to zip it’s content to a zip file

Example 1. ZipArchive.CreateFromDirectory(@”docs\attach”, “”);

Example 2. ZipArchive.ExtractToDirectory(“”, @”photos\January2012″);

What is ZipArchiveEntry?

ZipArchive represents a zip archive, which is a collection of entries, and ZipArchiveEntry represents an archived file entry.
A ZipArchive class (representing a zip file ) can have one or more ZipArchiveEntry class (representing normal files like text file, doc file, pdf file etc)

The following example extracts only the text files from an archive:

using (var archive = new ZipArchive(“”))

foreach (var entry in archive.Entries)

if (entry.FullName.EndsWith(“.txt”, StringComparison.OrdinalIgnoreCase))

entry.ExtractToFile(Path.Combine(directory, entry.FullName));




What is New in WCF 4.5?

In the .NET Framework 4.5 Developer Preview, the following features have been added to make it simpler to write Windows Communication Foundation (WCF) applications:

1- Simplification of generated configuration files.
2- Support for contract-first development.
3- Ability to configure ASP.NET compatibility mode more easily.
4- Changes in default transport property values to reduce the likelihood that you will have to set them.
5- Updates to the XmlDictionaryReaderQuotas class to reduce the likelihood that you will have to manually configure quotas for XML dictionary readers.
6- Validation of WCF configuration files by Visual Studio as part of the build process, so you can detect configuration errors before you run your application.
7- New asynchronous streaming support.
8- New HTTPS protocol mapping to make it easier to expose an endpoint over HTTPS with Internet Information Services (IIS).
9- Ability to generate metadata in a single WSDL document by appending ?singleWSDL to the service URL.
10- Websockets support to enable true bidirectional communication over ports 80 and 443 with performance characteristics similar to the TCP transport.
11- Support for configuring services in code.
12- XML Editor tooltips.
13- ChannelFactory caching support.
14- Binary encoder compression support.

Copyright © All Rights Reserved - C# Learners