I'm trying to compress some data in mono like this:
public static string Save(FlightProgram program, bool compressed)
{
using (MemoryStream ms = new MemoryStream())
{
BinaryFormatter f = new BinaryFormatter();
if (compressed)
{
using (DeflateStream gz = new DeflateStream(ms, CompressionMode.Compress))
{
f.Serialize(gz, program);
}
}
else
{
f.Serialize(ms, program);
}
return Convert.ToBase64String(ms.ToArray()).Replace('/', '_');
}
}
I'm simply getting the exception "CreateZStream". No inner exception. What's going on here ?
Stacktrace:
Could not save flight program: CreateZStream at at (wrapper managed-to-native) System.IO.Compression.DeflateStream:CreateZStream (System.IO.Compression.CompressionMode,bool,System.IO.Compression.DeflateStream/UnmanagedReadOrWrite,intptr)
at System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode, Boolean leaveOpen, Boolean gzip) [0x00000] in <filename unknown>:0
at System.IO.Compression.DeflateStream..ctor (System.IO.Stream compressedStream, CompressionMode mode) [0x00000] in <filename unknown>:0
at KSPComputerModule.ProgramSerializer.Save (KSPComputer.FlightProgram program, Boolean compressed) [0x00000] in <filename unknown>:0
at KSPComputerModule.FPComputer.OnSave (.ConfigNode node) [0x00000] in <filename unknown>:0 (State: None)