ZipUtility 1.2.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ZipUtility --version 1.2.0
NuGet\Install-Package ZipUtility -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZipUtility" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZipUtility --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZipUtility, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ZipUtility as a Cake Addin #addin nuget:?package=ZipUtility&version=1.2.0 // Install ZipUtility as a Cake Tool #tool nuget:?package=ZipUtility&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZipUtility;
namespace ZipUtilityTest
{
internal partial class ZipUtilityTest : Form
{
public ZipUtilityTest()
{
ZipViewer zipViewer = null;
string unzipDst = Application.StartupPath;
var statusStrip = new StatusStrip() { Parent = this, };
var statusLabel = new ToolStripStatusLabel() { Text = "Ready", Spring = true, TextAlign = ContentAlignment.MiddleLeft, };
statusStrip.Items.Add(statusLabel);
Action<string> progress = (l) => { statusLabel.Text = l; };
CheckBox checkBoxReportProgress = new CheckBox() { Text = "Report progress", Dock = DockStyle.Top, Checked = true, };
ListBox listBoxZipFiles = new ListBox() { Parent = this, Dock = DockStyle.Top, };
listBoxZipFiles.ContextMenuStrip = new ContextMenuStrip();
ToolStripMenuItem tsmiUnzip = new ToolStripMenuItem() { Text = "Unzip selected", };
tsmiUnzip.Click += async (sender, e) =>
{
await zipViewer.Extract(unzipDst, listBoxZipFiles.SelectedItems.Cast<string>().ToList());
};
ToolStripMenuItem tsmiGlimpse = new ToolStripMenuItem() { Text = "Glimpse selected", };
tsmiGlimpse.Click += (sender, e) =>
{
foreach (var item in listBoxZipFiles.SelectedItems.Cast<string>())
{
var d = zipViewer.GetData(item);
var text = Encoding.UTF8.GetString(d);
int len = Math.Min(200, text.Length);
MessageBox.Show(text.Substring(0, len));
}
};
ToolStripMenuItem tsmiGlimpseAsHex = new ToolStripMenuItem() { Text = "Glimpse first 16 bytes", };
tsmiGlimpseAsHex.Click += (sender, e) =>
{
if (zipViewer != null)
{
var bytedata = zipViewer.GetData(listBoxZipFiles.Text);
var text = new StringBuilder();
for (int i = 0; i < Math.Min(16, bytedata.Length); i++)
{
text.AppendFormat("{0:X2} ", bytedata[i]);
}
MessageBox.Show(text.ToString());
}
};
listBoxZipFiles.ContextMenuStrip.Items.Add(tsmiUnzip);
listBoxZipFiles.ContextMenuStrip.Items.Add(tsmiGlimpse);
Button buttonOpenZip = new Button() { Text = "Open an zip", Parent = this, Dock = DockStyle.Top, };
buttonOpenZip.Click += async (sender, e) =>
{
OpenFileDialog ofd = new OpenFileDialog() { InitialDirectory = Application.StartupPath,Filter = "*.zip;*.tar.gz|*.zip;*.tar.gz" };
if (ofd.ShowDialog() == DialogResult.OK)
{
zipViewer = await ZipViewer.Open(ofd.FileName, checkBoxReportProgress.Checked? progress: null);// progress);
listBoxZipFiles.Items.Clear();
if (zipViewer != null)
{
listBoxZipFiles.Items.AddRange(zipViewer.FileList.Select(x => x.FileName).ToArray());
progress(zipViewer.Type.ToString());
}
}
};
Button buttonExtract = new Button() { Text = "UnzipAll", Parent = this, Dock = DockStyle.Top, };
buttonExtract.Click += async (sender, e) =>
{
OpenFileDialog ofd = new OpenFileDialog() { InitialDirectory = Application.StartupPath, };
if (ofd.ShowDialog() == DialogResult.OK)
{
var tempdst = System.IO.Path.GetDirectoryName(ofd.FileName);
var z = await ZipViewer.Open(ofd.FileName, checkBoxReportProgress.Checked ? progress : null);
if (z != null)
{
await z.ExtractAll(tempdst);
}
}
};
Button buttonZip = new Button() { Text = "CreateZip", Parent = this, Dock = DockStyle.Top, };
buttonZip.Click += async (sender, e) =>
{
using (var streamzipper = new StreamZipper("streamzip.zip"))
{
OpenFileDialog ofd = new OpenFileDialog() { InitialDirectory = Application.StartupPath, Multiselect = true, };
if (ofd.ShowDialog() == DialogResult.OK)
{
foreach (var f in ofd.FileNames)
{
streamzipper.Add(f, System.IO.Path.GetFileName(f));
progress(f);
await Task.Delay(1);
}
}
FolderBrowserDialog fbd = new FolderBrowserDialog() { SelectedPath = Application.StartupPath, };
if (fbd.ShowDialog() == DialogResult.OK)
{
var startpos = System.IO.Path.GetDirectoryName(fbd.SelectedPath).Length;
foreach (var f in System.IO.Directory.GetFiles(fbd.SelectedPath, "*", System.IO.SearchOption.AllDirectories))
{
streamzipper.Add(f, f.Substring(startpos));
progress(f);
await Task.Delay(1);
}
}
streamzipper.Close();
streamzipper.Dispose();
progress("Ready");
}
};
listBoxZipFiles.ContextMenuStrip.Items.Add(tsmiGlimpseAsHex);
Controls.Add(checkBoxReportProgress);
SizeChanged += (sende, e) =>
{
listBoxZipFiles.Height = ClientSize.Height - buttonOpenZip.Height - buttonExtract.Height - buttonZip.Height - statusStrip.Height;
};
StartPosition = FormStartPosition.CenterScreen;
ClientSize = new Size(400, 600);
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- SharpZipLib (>= 1.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.6 | 74 | 10/31/2024 |
1.2.4 | 193 | 11/26/2023 |
1.2.2 | 185 | 6/29/2023 |
1.2.1 | 158 | 6/12/2023 |
1.2.0 | 182 | 4/8/2023 |
1.1.8 | 227 | 3/19/2023 |
1.1.6.1 | 348 | 11/5/2022 |
1.1.5 | 445 | 3/19/2022 |
1.1.4 | 437 | 2/9/2022 |
1.1.3 | 431 | 1/10/2022 |
1.1.2 | 265 | 12/26/2021 |
1.1.1 | 273 | 12/18/2021 |
1.0.9 | 295 | 11/23/2021 |
1.0.8 | 304 | 10/25/2021 |
1.0.7 | 291 | 10/22/2021 |
1.0.6 | 314 | 10/16/2021 |