folibis
folibis

Reputation: 12874

Save ZipArchive to file

In my application I have a class manipulating with zip archive using System.IO.Compression.ZipArchive. Now I want to save the entries of the archive to file. How can I do that? I know I can associate a Stream with archive but in my case the archive creates w/o streams and I can't change the code:

var archive = ZipFile.Open(fileName, ZipArchiveMode.Create);
// add entries
// how can I save it to file now?

Upvotes: 7

Views: 9207

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273464

You are already 'saving it to a file', the one indicated by fileName.

To make sure everything is written and flushed, use a using :

using (var archive = ZipFile.Open(fileName, ZipArchiveMode.Create))
{
   // add entries
   ....

}  // here it is saved and closed

Upvotes: 5

Related Questions