Opens the zip file for multiple operations.

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

Syntax

C#
public void OpenBatch()
Visual Basic
Public Sub 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.

Examples

The code below opens a zip file, adds several entries to it, then closes the file:
Copy CodeC#
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