Ummar Ummar - 8 months ago 60
C# Question

GZIP file Total length in C#

I have a zipped file having size of several GBs, I want to get the size of Unzipped contents but don't want to actually unzip the file in C#, What might be the Library I can use? When I right click on the .gz file and go to Properties then under the

Tab there is a property name
which is showing this value. But I want to get it Programmatically using C#.. Any idea?


The last 4 bytes of the gz file contains the length.

So it should be something like:

using(var fs = File.OpenRead(path))
  fs.Position = fs.Length - 4;
  var b = new byte[4];
  fs.Read(b, 0, 4);
  uint length = BitConverter.ToUInt32(b, 0);