Wednesday, 5 November 2014

Compress and Extract files to zip in Asp.net C#

using System;
using System.IO;
using System.IO.Compression;

namespace ConsoleApplicationZip
{
    class Program
    {
        static void Main(string[] args)
        {
            string startPath = @"c:\example\source";
            string zipPath = @"c:\example\source\result.zip";
            string extractPath = @"c:\example\destination";

            ZipFile.CreateFromDirectory(startPath, zipPath);

            ZipFile.ExtractToDirectory(zipPath, extractPath);
        }
    }
}

No comments:

Post a Comment