ZipUtility 1.2.6
dotnet add package ZipUtility --version 1.2.6
NuGet\Install-Package ZipUtility -Version 1.2.6
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.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZipUtility --version 1.2.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ZipUtility, 1.2.6"
#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.6 // Install ZipUtility as a Cake Tool #tool nuget:?package=ZipUtility&version=1.2.6
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");
}
};
Button buttonZipToByteArray = new Button() { Text = "CreateZip(byte[])", Parent = this, Dock = DockStyle.Top, };
buttonZipToByteArray.Click += async (sender, e) =>
{
/** If you want to get zipped binary or write the data by youself, set null to dstpath */
using (var streamzipper = new StreamZipper())
{
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);
}
}
//if dstpath is null, not saved when close called.
streamzipper.Close();
/** To get the Zipped binary data, use ZippedData after closing the streamzipper */
#if false
using (System.IO.FileStream fs = new System.IO.FileStream("streamzip.zip", System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
fs.Write(streamzipper.ZippedData, 0, streamzipper.ZippedData.Length);
}
#else
/** Also you can write the Zipped binary data to a file. */
streamzipper.Write("streamzip.zip");
#endif
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 | net461 is compatible. 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.
-
.NETFramework 4.6.1
- SharpZipLib (>= 1.4.2)
- System.Memory (>= 4.5.5)
- System.Numerics.Vectors (>= 4.5.0)
- System.Runtime.CompilerServices.Unsafe (>= 6.0.0)
- System.Threading.Tasks.Extensions (>= 4.5.4)
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 | 26 | 10/31/2024 |
1.2.4 | 192 | 11/26/2023 |
1.2.2 | 184 | 6/29/2023 |
1.2.1 | 157 | 6/12/2023 |
1.2.0 | 180 | 4/8/2023 |
1.1.8 | 226 | 3/19/2023 |
1.1.6.1 | 347 | 11/5/2022 |
1.1.5 | 444 | 3/19/2022 |
1.1.4 | 436 | 2/9/2022 |
1.1.3 | 422 | 1/10/2022 |
1.1.2 | 264 | 12/26/2021 |
1.1.1 | 272 | 12/18/2021 |
1.0.9 | 294 | 11/23/2021 |
1.0.8 | 303 | 10/25/2021 |
1.0.7 | 290 | 10/22/2021 |
1.0.6 | 313 | 10/16/2021 |