ZipUtility 1.1.5

.NET Framework 4.5.2
NuGet\Install-Package ZipUtility -Version 1.1.5
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.
dotnet add package ZipUtility --version 1.1.5
<PackageReference Include="ZipUtility" Version="1.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZipUtility --version 1.1.5
#r "nuget: ZipUtility, 1.1.5"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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.1.5

// Install ZipUtility as a Cake Tool
#tool nuget:?package=ZipUtility&version=1.1.5
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; };
        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));
            }
        };

        listBoxZipFiles.ContextMenuStrip.Items.Add(tsmiUnzip);
        listBoxZipFiles.ContextMenuStrip.Items.Add(tsmiGlimpse);

        Button buttonDisp = new Button() { Text = "Display", Parent = this, Dock = DockStyle.Top, };
        buttonDisp.Click += async (sender, e) =>
        {
            OpenFileDialog ofd = new OpenFileDialog() { InitialDirectory = Application.StartupPath, };
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                zipViewer = await ZipViewer.Open(ofd.FileName, progress);
                if (zipViewer != null)
                {
                    listBoxZipFiles.Items.Clear();
                    listBoxZipFiles.Items.AddRange(zipViewer.FileList.Select(x => x.FileName).ToArray());
                }
            }
        };

        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, progress);
                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");

            }
        };

        SizeChanged += (sende, e) =>
        {
            listBoxZipFiles.Height = ClientSize.Height - buttonDisp.Height - buttonExtract.Height - buttonZip.Height - statusStrip.Height;
        };
        StartPosition = FormStartPosition.CenterScreen;
        ClientSize = new Size(400, 600);
    }
}
Product Versions
.NET Framework net452 net46 net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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.1.5 103 3/19/2022
1.1.4 97 2/9/2022
1.1.3 101 1/10/2022
1.1.2 105 12/26/2021
1.1.1 129 12/18/2021
1.0.9 119 11/23/2021
1.0.8 147 10/25/2021
1.0.7 142 10/22/2021
1.0.6 163 10/16/2021