I want to compress a file and a directory in C#. I found some solution in Internet but they are so complex and I couldn\'t run them in my project. Can anybody suggest me a clear
For .Net Framework 4.5 this is the most clear example I found:
using System;
using System.IO;
using System.IO.Compression;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string startPath = @"c:\example\start";
string zipPath = @"c:\example\result.zip";
string extractPath = @"c:\example\extract";
ZipFile.CreateFromDirectory(startPath, zipPath);
ZipFile.ExtractToDirectory(zipPath, extractPath);
}
}
}
You'll need to add a reference to System.IO.Compression.FileSystem
From: https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-compress-and-extract-files