Used for creating, opening, and managing zip files.

Namespace:  C1.C1Zip
Assembly:  C1.Silverlight.Zip (in C1.Silverlight.Zip.dll)

Syntax

C#
public class C1ZipFile : IDisposable
Visual Basic
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 "cs" extension to the zip file:
Copy CodeC#
// get path for 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 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