Skip to content

Instantly share code, notes, and snippets.

@adamfisher
Created October 8, 2018 03:36
Show Gist options
  • Save adamfisher/40ef525a77e4e098e4a7f78d7d5b8710 to your computer and use it in GitHub Desktop.
Save adamfisher/40ef525a77e4e098e4a7f78d7d5b8710 to your computer and use it in GitHub Desktop.
/// <summary>
/// Gets the original file name from G-ZIP file.
/// </summary>
/// <returns>The decompressed file name.</returns>
private string GetFileNameFromGZipFile()
{
var bytes = File.OpenRead("abc.dat.gz");
bytes.ReadByte();
bytes.ReadByte();
var b = bytes.ReadByte();
if (b == 8)
{
var byteList = new List<byte>();
bytes.ReadByte();
bytes.ReadByte();
bytes.ReadByte();
bytes.ReadByte();
bytes.ReadByte();
bytes.ReadByte();
b = bytes.ReadByte();
while (b != 0)
{
byteList.Add((byte) b);
b = bytes.ReadByte();
}
return Encoding.ASCII.GetString(byteList.ToArray());
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment