Save ZipArchive to file

In my application, I have a class that processes a zip archive using System.IO.Compression.ZipArchive . Now I want to save the archive entries to a file. How can i do this? I know that I can associate Stream with the archive, but in my case the archive creates without streams, and I cannot change the code:

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

You already "save it to a file", the one specified by fileName .

To have everything written and reset, use using :

 using (var archive = ZipFile.Open(fileName, ZipArchiveMode.Create)) { // add entries .... } // here it is saved and closed 
+3
source

Source: https://habr.com/ru/post/1264785/


All Articles