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

 

posted @ 2020-06-08 17:40  FredGrit  阅读(151)  评论(0编辑  收藏  举报