Exemplo n.º 1
0
 /// <summary>
 /// 压缩指定文件到指定路径
 /// </summary>
 /// <param name="files">指定的待压缩文件</param>
 /// <param name="destFileName">压缩路径</param>
 public void compressTo(object sender, ZipEventSource.ZipEventArgs e)
 {
     string[] files = e.files;
     string destFileName = e.filePath;
     totalSize = getFileTotalSize(files);
     eventListener.HandlePrgressBar(null, new ZipEventListener.ZipProgressBarEventArgs(ZipEventListener.ZipProgressBarEventValue.BEGIN, 0));
     // 开始压缩操作
     using (ZipOutputStream outs = new ZipOutputStream(File.Create(destFileName)))
     {
         outs.SetLevel(9);
         byte[] buffer = new byte[4096];
         compress(files, "", outs, ref buffer, ref compressedSize);
         outs.Finish();
     }
 }
Exemplo n.º 2
0
 public MainWindow()
 {
     InitializeComponent();
     zipUtil = new ZipUtil(this);
     eventHandler = new ZipEventSource();
     eventHandler.Compress += zipUtil.compressTo;
 }