Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Hi I have a need to deserialize an XML file which contains an image in base64 string. When I deserialize the XML the image is straight away populated as bytes by the following class. Which pretty much eliminates the need to do anything fancy and I write the image from those bytes. However a few images print as corrupt while others are perfectly fine. I need to resolve why few images are corrupt. Either the source is incorrect or I am missing something.

My question is 'is it necessary to use Convert.FromBase64String() function to convert the base64 string to bytes?' Doing this doesn't really make a difference anyway.

I suppose that the XML deserialization process automatically does that job

Can anybody please provide a credible source for whatever the case maybe?

Public Class Graphics_Data
  Private _Image_Graphic As List(Of Byte())
  <XmlElement("Image_Graphic")>
  Public Property Image_Graphic As List(Of Byte())
    Get
        Return _Image_Graphic
    End Get
    Set(value As List(Of Byte()))
        _Image_Graphic = value
    End Set
 End Property
End Class
share|improve this question
what language/library? It depends a lot on that. – Fakrudeen 25 mins ago
@Fakrudeen This is in VB.Net and I am using XmlSerializer.Deserialize() function to deserialize the XML. And I would have thought that function automatically detects the encoding and does the job of converting, which seems the case in my testing. – hrishi 21 mins ago

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.