- You can download the latest version of SharpZipLib to http://www.icsharpcode.net/opensource/sharpziplib/, support zip, GZip, BZip2 and tar formats, the author's project code is as follows
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;//from the project icsharpcode-sharpziplib-e012155 generated 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 Fo Lderbrowserdialog ())
{
//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 ("Compression done! "," Information Hint: ", 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 + "\ \ New Folder", "");
Fz. Createzip ("123.zip", dlg. SelectedPath, True, "");
MessageBox.Show ("Unzip done! "," Information Hint: ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show (ex. ToString ());
Throw
}
}
}
}
Project
Zip Compression decompression Project icsharpcode-sharpziplib-e012155