My decompressing worked fine for years!
But now I have some files that abort while decompressing after a few reads.
The decompression will abort after 694 records but there are 1'829'768 records!
I do not receive any error from the GZipStream.
I am afraid, the Problem is not the code but a bug or missing feature in GZipStream of Microsoft.
I assume that the file was compressed using some UNIX environment.
I can decompress it from the shell using WinRar or ZIP but I can't decompress them "on-the-fly", using GZipStream.
Decompressing first and processing afterwards is of course possible but not an option, because some of these files are to big. (Terra bytes). This would waste way to much time.
using System;
using System.Data;
using System.IO;
using System.IO.Compression;
public static void Unpack(string p_sZippedFileName)
{
const int cRecordLenght = 986;
byte[] ba = new byte[cRecordLenght];
int iRecordCounter = 0;
using (FileStream fileStream = new FileStream(p_sZippedFileName, FileMode.Open, FileAccess.Read))
using (GZipStream zipStream = new GZipStream(fileStream, CompressionMode.Decompress))
{
while (zipStream.Read(ba, 0, cRecordLenght) != 0)
{
iRecordCounter++;
}
Console.WriteLine("\nfinished after " + iRecordCounter.ToString() + " records ");
}
}
static void Main(string[] args)
{
Unpack(@"MyGzFile.gz");
}
The compressed file is 15MB in size and 1.7GB uncompressed. It should have 1'829'768 records! Not 694!
Unfortunately you need to download the 15MB datafile to see this effect.