Created
October 8, 2018 03:36
-
-
Save adamfisher/40ef525a77e4e098e4a7f78d7d5b8710 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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