ComponentOne Zip for .NET 2.0
C1.Zip Assembly / C1.Zip Namespace / C1ZipFile Class / OpenBatch Method
Example

In This Topic
    OpenBatch Method
    In This Topic
    Opens the zip file for multiple operations.
    Syntax
    Public Sub OpenBatch() 
    public void OpenBatch()
    Remarks

    By default, C1ZipFile opens and closes the zip file automatically whenever entries are added or removed.

    This can cause delays in systems that have certain types of anti-virus software installed, or in situations where you want to add a large number of relatively small entries. In these cases, use the OpenBatch and CloseBatch methods to keep the zip file open until the entire operation is concluded.

    Use a finally clause to ensure that the CloseBatch method is called even if an exception occurs.

    Example
    The code below opens a zip file, adds several entries to it, then closes the file:
    C1ZipFile zip = new C1ZipFile();
    zip.Open(myzipfile);
    try
    {
    	zip.OpenBatch();
    	foreach (string fileName in Directory.GetFiles(path, "*.*"))
    		zip.Entries.Add(fileName);
    }
    finally
    {
    	zip.CloseBatch();
    }
    See Also