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

Posted LongtengGensSupreme

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zip压缩解压缩 项目icsharpcode-SharpZipLib-e012155相关的知识,希望对你有一定的参考价值。

 

  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的主要内容,如果未能解决你的问题,请参考以下文章

如何在Linux下解压缩“.7z”文件?急啊!

nodejs压缩解压缩(加密)

zip压缩和unzip解压缩

centos 怎么解压缩zip

unzip---解压缩“.zip”压缩包。

zip---解压缩文件