ComponentOne Zip for .NET
C1.C1Zip.4.5.2 Assembly / C1.C1Zip Namespace / C1ZipFile Class
Members Example

In This Topic
    C1ZipFile Class
    In This Topic
    Used for creating, opening, and managing zip files.
    Object Model
    C1ZipFile ClassC1ZipEntryCollection ClassC1ZipEntry Class
    Syntax
    Public Class C1ZipFile 
    public class C1ZipFile 
    Remarks

    Use the Open(Stream) or Create(Stream) 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).

    Example
    The code below creates a zip file called sources.zip and adds all files with a "cs" extension to the zip file:
    // 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