I have two files (I use 7zip): n1.txt.gz and n2.txt.gz. Then I combine them to the file n12.txt.gz by command prompt:
type n1.txt.gz > n12.txt.gz
type n2.txt.gz >> n12.txt.gz
If I decompress the file n12.txt.gz by 7zip, I will get combined decompressed original files (n1.txt + n2.txt). But if I use this code
public static void Decompress2(String fileSource, String fileDestination, int buffsize)
{
using (var fsInput = new FileStream(fileSource, FileMode.Open, FileAccess.Read))
{
using (var fsOutput = new FileStream(fileDestination, FileMode.Create, FileAccess.Write))
{
using (var gzipStream = new GZipStream(fsInput, CompressionMode.Decompress))
{
var buffer = new Byte[buffsize];
int h;
while ((h = gzipStream.Read(buffer, 0, buffer.Length)) > 0)
{
fsOutput.Write(buffer, 0, h);
}
}
}
}
}
I will get just decompressed first part of n12.txt.gz, i.e. decompressed n1.txt.
Why does GZipStream stop after first part of combined file? And how does 7zip decompress the whole file?