Answers for "c# make zip file"

C#
4

c# zip a file

using System;
using System.IO.Compression;

class Program
{
    static void Main(string[] args)
    {
        string startPath = @".start";
        string zipPath = @".result.zip";
        string extractPath = @".extract";

        ZipFile.CreateFromDirectory(startPath, zipPath);

        ZipFile.ExtractToDirectory(zipPath, extractPath);
    }
}
Posted by: Guest on May-14-2020
-1

open zip file in c#

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

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string zipPath = @"c:usersexampleuserstart.zip";
            string extractPath = @"c:usersexampleuserextract";
            string newFile = @"c:usersexampleuserNewFile.txt";

            using (ZipArchive archive = ZipFile.Open(zipPath, ZipArchiveMode.Update))
            {
                archive.CreateEntryFromFile(newFile, "NewEntry.txt");
                archive.ExtractToDirectory(extractPath);
            }
        }
    }
}
Posted by: Guest on June-14-2020

C# Answers by Framework

Browse Popular Code Answers by Language