How To Create Zip File Using C# Code

In this article, I will explain that how we can create a Zip file from the directory using C# code.

Add DLL References

  • System.IO.Compression.FileSystem.dll

C# Code

using System;
using System.IO.Compression;

namespace CreateZip
    class Program
        static void Main(string[] args)
            //Create Zip file
            ZipFile.CreateFromDirectory(@"D:\Icons", @"D:\");

ZipFile.CreateFromDirectory will create the zip file from the directory. You need to pass the source directory path as a first parameter and the zip file name with the path as a second parameter.


Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories