I know there are libraries out there for working with ZIP files. And, you can alternatively use the functionality built into Windows for working ZIP files.
But, I\'m
Since .NET 4.5, Microsoft has offered the ZipArchive class to the System.IO.Compression
namespace. Unlike other classes in that namespace, though, like GZipStream
and Deflate
stream, the ZipArchive
requires a reference to the System.IO.Compression.dll assembly.
It's fairly simple to use, and the link above to MSDN provides some good examples.
Additionally, Microsoft has created the Microsoft Compression NuGet package, which adds support for ZipArchive
and related classes to Windows Phone 8 and other Portable Class Libraries
public static void zIpDatabseFile(string srcPath, string destPath)
{//This is for Zip a File
using (var source = new FileStream(srcPath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var dest = new FileStream(destPath, FileMode.OpenOrCreate, FileAccess.Write))
using (var zip = new GZipStream(dest, CompressionMode.Compress))
{
source.CopyTo(zip);
}
}
public static void uNzIpDatabaseFile(string SrcPath, string DestPath)
{// This is for unzip a files.
using (var source = new FileStream(SrcPath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var dest = new FileStream(DestPath, FileMode.OpenOrCreate, FileAccess.Write))
using (var zip = new GZipStream(source, CompressionMode.Decompress))
{
zip.CopyTo(dest);
}
}