Hi,
I'm trying to read binary information from an XMLTextReader and to save
it to a .jpg file, using a FileStream. I don't want to use an
XmlDocument because of performance reasons. But the only example code I
could find is:
byte[] binhex = new byte[1000];
do {
binhexlen = reader.ReadBinHex(binhex, 0, 50);
for (int i=0; i < binhexlen; i++) Console.Write(binhex[i]);
} while (reader.Name == "BinHex");
Is there any way to discover the length of the binary data on
beforehand? Or can someone give me a hint on how to complete my code
hereunder?
oPreviewStream = new FileStream(@"c:\temp\temp.jpg",
FileMode.Create, FileAccess.Write);
if (oPreviewStream != null)
{
// oTextReader.Value.Length returns zero in this case, I
suppose because of the binary content.
byte[] byteStream = new byte[oTextReader.Value.Length];
oTextReader.ReadBinHex(byteStream, 0,
oTextReader.Value.Length - 1);
oPreviewStream.Write(byteStream, 0, byteStream.Length);
oPreviewStream.Flush();
oPreviewStream.Close();
}
(This code snippet is not complete and not working).
Thanks in advance for the help. Kind regards,
Karine Bosch