Used for creating, opening, and managing zip files.

Namespace:  C1.C1Zip
Assembly:  C1.C1Zip.2 (in C1.C1Zip.2.dll)

Syntax

C#
[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
[GuidAttribute("C5AE6DB9-02C1-4240-9B2D-D0F76A23E32B")]
public class C1ZipFile : IDisposable
Visual Basic (Declaration)
<ClassInterfaceAttribute(ClassInterfaceType.AutoDual)> _
<GuidAttribute("C5AE6DB9-02C1-4240-9B2D-D0F76A23E32B")> _
Public Class C1ZipFile _
	Implements IDisposable

Remarks

Use the Open(String) or Create(String) methods to associate the C1Zip file object with a zip file on disk. Then use the Entries property to add, remove, retrieve, or inspect individual entries in the zip file.

C1ZipFile can only be used with standard zip files. The component does not support other similar formats such as gzip, zip2, tar, or rar.

The standard zip file imposes some limitations on the size of each entry. You cannot use it to compress files larger than 4 gigabytes (uint.MaxValue).

Examples

The code below creates a zip file called sources.zip and adds all files with a ".vb" extension for Visual Basic or ".cs" extension for C# to the zip file:

Copy CodeVisual Basic
' Get the path for the zip file and files to compress.Dim path AsString = Application.ExecutablePath
Dim pos AsInteger = path.IndexOf("\bin") 
path = path.Substring(0, pos + 1)
' Create a zip file.Dim zip AsNew C1ZipFile()
zip.Create((path + "source.zip"))
' Add all files with extension .vb to the zip file.Dim fileName AsStringForEach fileName In  Directory.GetFiles(path, "*.vb")
    zip.Entries.Add(fileName)
Next fileName
' Show the result.Dim ze As C1ZipEntry
ForEach ze In  zip.Entries
    Console.WriteLine("{0} {1:#,##0} {2:#,##0}", ze.FileName, ze.SizeUncompressed, ze.SizeCompressed)
Next ze
Copy CodeC#
// Get the path for the zip file and files to compress.string path = Application.ExecutablePath;
int pos = path.IndexOf(@"\bin");
path = path.Substring(0, pos + 1);
// Create a zip file.
C1ZipFile zip = new C1ZipFile();
zip.Create(path + "source.zip");
// Add all files with extension .cs to the zip file.foreach (string fileName in Directory.GetFiles(path, "*.cs"))
{
    zip.Entries.Add(fileName);
}
// Show the result.foreach (C1ZipEntry ze in zip.Entries)
{
    Console.WriteLine("{0} {1:#,##0} {2:#,##0}", ze.FileName, ze.SizeUncompressed, ze.SizeCompressed);
}

Inheritance Hierarchy

System..::.Object
  C1.C1Zip..::.C1ZipFile

See Also