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);
        }

 

你可能感兴趣的:(C# zip folder)