Zipping Files with CSharpZipLib

The title says it all. The code below:

using ICSharpCode.SharpZipLib.Zip;

using (ZipFile zip = ZipFile.Create(fullFileName))
{
    zip.Password = password;
    zip.NameTransform = new ZipNameTransform(path);
    zip.BeginUpdate();
    foreach (string file in arquivos)
    {
        string sourceFile = path + file;
        try
        {
            zip.Add(sourceFile);
        }
        catch (Exception ex)
        {
            arquivosErros.Add(file);
        }
    }
    zip.CommitUpdate();
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s