Compress folders in C#

Compress folders in C#

Compressing files and folders can easily be done by using system.io.compression

namespace ZipSourceCode
{
using System;
using System.IO;
using System.IO.Compression;

class Compress
{
/// <summary>
/// Compress files and folders using System.IO.Compression
/// http://msdn.microsoft.com/en-us/library/system.io.compression(v=vs.110).aspx
/// </summary>
public void CompressFiles()
{
string sourceFolder = @"C:\Dev\Clients\Cupofdev";
string targetFolder = @"C:\CodeDumps";
ZipFile.CreateFromDirectory(sourceFolder, Path.Combine(targetFolder, "sourcecode.zip"), CompressionLevel.Optimal, true);
}
}
}