What I have: Xml file created with ChilkatDotNet4
's Xml
class, some node in that file with binary content (data in code below is byte array). zipFlag that is passed to SetBinaryContent
show that content would be zipped. How file is being created:
var zipFlag = true;
var ecryptFlag = false;
var password = string.empty;
var xml = new Xml();
var node = xmlFile.FindChild("SomeNode");
node.SetBinaryContent(data, zipFlag, ecryptFlag, password); //in file it is base64 text
What I need: to read this file with System.Xml.XmlDocument
, and get the binary content from the "SomeNode" node.
What I've tried: read innerText of "SomeNode", get byte array with FromBase64String
, and then unzip with GZipStream
, but got InvalidDataException
(The magic number in GZip header is not correct. Make sure you are passing in a GZip stream)
I strongly believe that someone has already faced the same problem.
The binary data is the output of the deflate algorithm (no GZip structure enclosing it). I suspect System.IO.Compression.DeflateStream will do it.