Please excuse me if I have misunderstood your initial question.
In order to unzip a zip file using the ZipLibrary, you need to do the following steps:
1) Open the Zip file:
using (ZipPackage zipFile = ZipPackage.OpenFile(zipFilePath, FileAccess.Read))
2) Traverse through all its items in the zipFile.ZipPackageEntries collection.
foreach (var zipEntry in zipFile.ZipPackageEntries)
3) Open the decompressed stream of each entry
Stream strm = zipEntry.OpenInputStream();
4) Create new byte to contain the zipped data. Please note that this array should be with the size of the UncompressedFile size.
byte Bytes = new byte[zipEntry.UncompressedSize];
5) Read the bytes from the decompressed stream
strm.Read(Bytes, 0, (int)zipEntry.UncompressedSize);
6) Access the filename and its extension in the zipEntry.FileNameInZip property
7) Create a new file for each entry
string extractedFilePath = path + @"\New" + fileName;
using (FileStream fs = new FileStream(extractedFilePath, FileMode.Create))
fs.Write(Bytes, 0, Bytes.Length);
I have attached a sample project demonstrating the approach. Run the attached project press the "Create ZIP file" button, then press the "Extract" button to extract the zipped files.
I hope this information helps.
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>