C#.net identify zip file

This is a base class for a component that needs to handle data that is either uncompressed, PKZIP compressed (sharpziplib) or GZip compressed (built in .net). Perhaps a bit more than you need but should get you going. This is an example of using @PhonicUK’s suggestion to parse the header of the data stream. The … Read more

Using SharpZipLib to unzip specific files?

ZipFile.GetEntry should do the trick: using (var fs = new FileStream(sourcePath, FileMode.Open, FileAccess.Read)) using (var zf = new ZipFile(fs)) { var ze = zf.GetEntry(fileName); if (ze == null) { throw new ArgumentException(fileName, “not found in Zip”); } using (var s = zf.GetInputStream(ze)) { // do something with ZipInputStream } }