Insert image into xml file using c# Insert image into xml file using c# xml xml

Insert image into xml file using c#


  1. Read all the bytes into memory usingFile.ReadAllBytes().
  2. Convert the bytes to a Base64 stringusing Convert.ToBase64String().
  3. Write the Base64 Encoded string toyour element content.

Doneski!


Here's an example in C# for writing and reading images to/from XML.


You can use a CDATA part or simply put all the bytes in their hexadecimal form as a string.Another option is to use a base64 encoding

The element you use is up to you.