C# zip folder
static void ZipFolderDemo() { string path = Directory.GetCurrentDirectory(); string zippedFile = Path.Combine(path, path+".zip"); Console.WriteLine($"Zipped file {zippedFile}"); ZipFile.CreateFromDirectory(dir, zippedFile,CompressionLevel.Optimal,true); }
static void ZipExtractDemo() { string sourceZippedFile = Directory.GetCurrentDirectory() + ".zip"; string unzippedFile = Path.GetFileNameWithoutExtension(sourceZippedFile)+"2"; ZipFile.ExtractToDirectory(sourceZippedFile, unzippedFile); }