码迷,mamicode.com
首页 > 其他好文 > 详细

zip压缩解压缩 项目icsharpcode-SharpZipLib-e012155

时间:2016-04-02 13:24:32      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

 

  1. 大家可以到http://www.icsharpcode.net/opensource/sharpziplib/ 下载SharpZiplib的最新版本,支持Zip, GZip, BZip2 和Tar格式,本作者的项目代码如下

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.SharpZipLib.Zip;//来自项目icsharpcode-SharpZipLib-e012155生成的ICSharpCode.SharpZipLib.dll

namespace TestZIP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
try
{
using (FolderBrowserDialog dlg = new FolderBrowserDialog())
{
//dlg.CheckFileExists = true;
//dlg.CheckPathExists = true;
if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
if (dlg.SelectedPath != null)
{
FastZip fz = new FastZip();
fz.CreateZip("123.zip", dlg.SelectedPath, true, "");
MessageBox.Show("压缩完成!", "信息提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
//throw;
}
}

private void button2_Click(object sender, EventArgs e)
{
try
{
using (OpenFileDialog dlg = new OpenFileDialog())
{
//dlg.CheckFileExists = true;
//dlg.CheckPathExists = true;
if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
if (dlg.FileName != null)
{
FastZip fz = new FastZip();
fz.ExtractZip(dlg.FileName, Application.StartupPath + "\\新建文件夹", "");
//fz.CreateZip("123.zip", dlg.SelectedPath, true, "");
MessageBox.Show("解压完成!", "信息提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
//throw;
}
}
}
}

 

项目技术分享

zip压缩解压缩 项目icsharpcode-SharpZipLib-e012155

标签:

原文地址:http://www.cnblogs.com/1175429393wljblog/p/5347316.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!