基于.NET 4.5 压缩的使用(2)


static void Main(string[] args)
        {
            Stopwatch watch = new Stopwatch();
            watch.Start();
            string path = @"E:\";
            Compress(path, @"F:\4.5.zip");
            watch.Stop();
            Console.WriteLine("消耗时间:{0}", watch.ElapsedMilliseconds);
            FileInfo f = new FileInfo(@"F:\4.5.zip");
            Console.WriteLine("文件大小{0}", f.Length);
        }
        static void Compress(string filePath, string zipFilePath)
        {
            ZipFile.CreateFromDirectory(filePath, zipFilePath, CompressionLevel.Fastest, false);
        }


怎么样代码是不是简洁了很多呢?

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjgsjp.html