Tutorial by Examples

This snippet will list all the filenames of a zip archive. The filenames are relative to the zip root. using (FileStream fs = new FileStream("archive.zip", FileMode.Open)) using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Read)) { for (int i = 0; i < archive.Entries....
Extracting all the files into a directory is very easy: using (FileStream fs = new FileStream("archive.zip", FileMode.Open)) using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Read)) { archive.ExtractToDirectory(AppDomain.CurrentDomain.BaseDirectory); } When the file...
To update a ZIP file, the file has to be opened with ZipArchiveMode.Update instead. using (FileStream fs = new FileStream("archive.zip", FileMode.Open)) using (ZipArchive archive = new ZipArchive(fs, ZipArchiveMode.Update)) { // Add file to root archive.CreateEntryFromFile(&qu...

Page 1 of 1