Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read data from a zip file without having to unzip the entire file

Is there anyway in .Net (C#) to extract data from a zip file without decompressing the complete file?

I possibly want to extract data (file) from the start of a zip file if the compression algorithm compress the file used was in a deterministic order.

like image 303
AwkwardCoder Avatar asked May 11 '11 16:05

AwkwardCoder


1 Answers

With .Net Framework 4.5 (using ZipArchive):

using (ZipArchive zip = ZipFile.Open(zipfile, ZipArchiveMode.Read))     foreach (ZipArchiveEntry entry in zip.Entries)         if(entry.Name == "myfile")             entry.ExtractToFile("myfile"); 

Find "myfile" in zipfile and extract it.

like image 101
Sinatr Avatar answered Sep 23 '22 06:09

Sinatr