基本信息
源码名称:C# 解压文件/压缩文件 示例源码(带进度条)
源码大小:4.05M
文件格式:.zip
开发语言:C#
更新时间:2018-08-04
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
压缩文件为7z格式

using System;
using System.IO;

namespace ProgressBarSolution
{
    class Program
    {
        static void Main(string[] args)
        {
            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"files", "book.pdf");
            string zipFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"files", "book.7z");
            try
            {
                Console.WriteLine();
                Console.WriteLine("正在压缩文件...");
                ProgressBar progressBar = new ProgressBar(Console.CursorLeft, Console.CursorTop, 50, ProgressBarType.Character);
                GZipHelper.Compress(filePath, progressBar.Dispaly);
                Console.WriteLine();

                Console.WriteLine();
                Console.WriteLine("正在解压文件...");
                progressBar = new ProgressBar(Console.CursorLeft, Console.CursorTop, 50, ProgressBarType.Multicolor);
                GZipHelper.Decompress(zipFilePath, filePath, progressBar.Dispaly);
                Console.WriteLine();
               
            }
            catch (System.ArgumentOutOfRangeException ex)
            {
                Console.Beep();
                Console.WriteLine("进度条宽度超出可显示区域!");
            }
            finally
            {
                Console.WriteLine();
                Console.WriteLine("操作完成,按任意键退出!");
                Console.ReadKey(true);
            }
        }
    }
}