Click here to Skip to main content
15,886,701 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi All,

I want to store physical file like JPEGs, PNGs etc. in XML file means XML serialization. How can do this ?

Rgds,
Sachin Panchal
Posted
Comments
Sergey Alexandrovich Kryukov 31-Jan-11 0:50am    
Good question, should useful for others - my 5.
Please see my Answer - may be it's the easiest.
--SA

Hi,

try this article:
Load and save objects to XML using serialization[^]

or just google for "story binary file in xml c#" - this will give you a lot more interesting links.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 31-Jan-11 0:49am    
I would say my advice is simpler and would suffice. What do you think?
I voted 5, anyway.
Thank you.
--SA
JF2015 31-Jan-11 0:53am    
Yes, it's really a very simple solution that everyone should keep in mind when doing these kinds of serialization but I do like to answer with CP articles since they tend to be more informative than the short msdn pages. But as you are totally right - 5'ed yours!
Sergey Alexandrovich Kryukov 31-Jan-11 1:02am    
Thank you. And yes, I understand your motivation about CodeProject, but it could be anything else as well.
--SA
Espen Harlinn 31-Jan-11 14:54pm    
Good answer, solution is easy to extend and refine 5+
One way to do it is converting a file into Base64 format, see http://msdn.microsoft.com/en-us/library/dhx0d524.aspx[^]; convert it back: http://msdn.microsoft.com/en-us/library/system.convert.frombase64string.aspx[^].

This string format is XML-safe, store it as any human-readable string without special characters.
That's it!

Good luck.
—SA
 
Share this answer
 
Comments
Espen Harlinn 31-Jan-11 14:52pm    
Nice and simple 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900