Click here to Skip to main content
12,996,261 members (67,529 online)
Click here to Skip to main content
Add your own
alternative version


47 bookmarked
Posted 13 Jun 2001

Passing binary data in xml: a C# example which puts and gets icon and bitmaps to and from a xml file.

, 13 Jun 2001
Rate this:
Please Sign up or sign in to vote.
Binary data needs to be base64 encoded to go into an xml file. .Net framework has made this a painless method wiht its System.Xml namespce classes. I use the XmlTextWriter to put in a bitmap and icon image into a xml file. I then use XmlTextReader to parse the xml file and dynamically set the icon a
<!-- Article image -->

Sample Image - screen_shot_Genx.jpg

<!-- Add the rest of your HTML here -->


Looking at the .resx file that VS.NET uses to store resources such as images, I thought wouldn't it be cool to have a XML file where you can store images and other info for you app and at startup your app gets the look and feel from the XML file dynamically. You can then change the look and feel by changing the XML file, maybe over the internet! A little investigation showed that .NET namespace System.XML has 2 great classes XMLTextWriter and XMLTextReader which does all the hard work for you with their Read/WriteBase64 methods.



So here is my quick and dirty app, which uses 2 classes CLookXMLReader and CLookXMLWriter to do the putting in the binary and getting the binary out to bitmap or an icon. You basically use the Writer to put the images into the XML, then the reader can be used at a separate app to get the images out from the XML. Made the code a bit messy when reading the binary out from the XML, there must be a better way to it, please let me know! I hope you dont judge coding skills by just looking at this app only (I am usually much better!) :)


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Wahid Choudhury
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralXML file with binary data Pin
sranu26-Oct-10 7:38
membersranu26-Oct-10 7:38 
GeneralPassing Binar/Image data to a web service Pin
sheel prabhakar14-Sep-10 1:40
membersheel prabhakar14-Sep-10 1:40 
QuestionHow to convert .ai file(Adobe Illustrator File) to .bmp(BitMap) file in c# Pin
Santhosh_B_K16-Apr-07 1:08
memberSanthosh_B_K16-Apr-07 1:08 
Questionhow do I pass an image from nodes in the xml to a component on a form Pin
Try748-Jan-07 1:15
memberTry748-Jan-07 1:15 
Generalssl code Pin
saroj yadav16-Oct-06 1:20
membersaroj yadav16-Oct-06 1:20 
GeneralThank You Pin
dboucher21-Jul-05 17:01
memberdboucher21-Jul-05 17:01 
GeneralBinary to XML to Binary to XML fails Pin
nordhaus18-May-05 11:34
membernordhaus18-May-05 11:34 
GeneralXmlTextReader and binary data Pin
Anonymous10-Dec-02 4:45
sussAnonymous10-Dec-02 4:45 
Generaldbconsts.obj Pin
Reza_Y20-Sep-02 22:07
sussReza_Y20-Sep-02 22:07 
GeneralSending the image size Pin
Vinla20-Sep-02 0:24
memberVinla20-Sep-02 0:24 
GeneralBitmap to a bytearray Pin
jeetu26-Aug-02 4:44
memberjeetu26-Aug-02 4:44 
GeneralRe: Bitmap to a bytearray Pin
Kamen Nikolov26-Sep-03 6:45
memberKamen Nikolov26-Sep-03 6:45 
GeneralRe: Bitmap to a bytearray Pin
Kamen Nikolov26-Sep-03 6:55
memberKamen Nikolov26-Sep-03 6:55 
GeneralXml bunary vb6 problem in c# Pin
bcapuano30-Jul-02 12:25
memberbcapuano30-Jul-02 12:25 
GeneralRe: Xml bunary vb6 problem in c# Pin
Anonymous4-Oct-02 11:44
sussAnonymous4-Oct-02 11:44 
GeneralXml Quik Buider Pin
shak30-Jun-02 19:48
membershak30-Jun-02 19:48 
GeneralRe: Xml Quik Buider Pin
Christian Graus30-Jun-02 20:09
memberChristian Graus30-Jun-02 20:09 
QuestionCan you encode the binary information to a string Pin
Anonymous13-Jul-01 10:56
memberAnonymous13-Jul-01 10:56 
AnswerRe: Can you encode the binary information to a string Pin
Todd Smith13-Jul-01 11:36
memberTodd Smith13-Jul-01 11:36 
GeneralRe: Can you encode the binary information to a string Pin
Anonymous16-Jul-01 8:51
memberAnonymous16-Jul-01 8:51 
GeneralRe: Can you encode the binary information to a string Pin
Nathan Blomquist12-Jun-02 6:07
memberNathan Blomquist12-Jun-02 6:07 
GeneralAnything like this in C++ Pin
Darren Schroeder16-Jun-01 10:39
memberDarren Schroeder16-Jun-01 10:39 
GeneralRe: Anything like this in C++ Pin
wahid18-Jun-01 5:02
memberwahid18-Jun-01 5:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170609.2 | Last Updated 14 Jun 2001
Article Copyright 2001 by Wahid Choudhury
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid