We have a Winform client app that is comsuming a web service we write. This client app requests documents that are contained in XML files, generally a PDF written to a base64 encoded binary field in the XML file.
Client successfully downloads, decodes, and opens 99% of the documents correctly.
However, we've started encountering some files that are failing when the client makes this call:
byte[] buffer = Convert.FromBase64String(xNode["fileIMAGE"].InnerText);
System.FormatException-
Message="Invalid character in a Base-64 string."
Source="mscorlib"
We've written out the base64 blob from the XML file to a text file. I don't see any "\0" characters. I could post the whole blob, but it's quite large.
Any ideas?
isalnum(),+, or/? That ought to leave a big pile of newlines or crlf or similar, padding at the end, and your mystery character.=in the middle sounds troublesome. Can you try your encoding routines on small inputs? Generate random byte strings between ten bytes and ten kilobytes, maybe you'll generate one by happy accident that shows the problem.