I'm running into some strange machine/OS dependent GZipStream behavior in .NET 4.0. This is the relevant code:
public static string Compress(string input) {
using(var ms = new MemoryStream(Encoding.UTF8.GetBytes(input)))
using(var os = new MemoryStream()) {
using(var gz = new GZipStream(os,CompressionMode.Compress,true)) {
ms.CopyTo(gz);
}
return string.Join("",os.ToArray().Select(b=>b.ToString("X2")));
}
}
Running Compress("freek") gives me
1F8B08000000000004004B2B4A4DCD06001E33909D05000000
on Windows 7 and
1F8B0800000000000400ECBD07601C499625262F6DCA7B7F4AF54AD7E074A10880601324D8904010ECC188CDE692EC1D69472329AB2A81CA6556655D661640CCED9DBCF7DE7BEFBDF7DE7BEFBDF7BA3B9D4E27F7DFFF3F5C6664016CF6CE4ADAC99E2180AAC81F3F7E7C1F3F22CEEB3C7FFBFF040000FFFF1E33909D05000000
on Windows Server 2008R2. Both are 64bit. I would expect the results to be the same.
Both machines give the correct result when I decompress either result. I already found out that on W7 ms.Length == 25 while on W2K8R2 ms.Length==128, but no clue why.
What's going on?