store binary data in text format

  • Thread starter Thread starter Wiktor Zychla
  • Start date Start date
W

Wiktor Zychla

I would like to store some binary data inside my own XML file under some
nodes.

I can convert the whole binary file byte-by-byte by myself but are there any
more efficient and ellegant ways? I tried to use ResXResourceWriter class
but it stores the whole ResX file and what I need is only the text-encoded
binary data (i.e. the content of /data/value from such ResX).

for example:

Image i = Image.FromFile( ... );
// ? how to convert the binary data from i to the text format?

// this is NOT what I want because it writes whole ResX file
System.IO.StreamWriter sw = new StreamWriter( @"c:\000\puch.sv" );

ResXResourceWriter rw = new ResXResourceWriter( sw );

rw.AddResource( "Image", b );



Thanks for your help,

Wiktor
 
Wiktor Zychla said:
I would like to store some binary data inside my own XML file under some
nodes.

I can convert the whole binary file byte-by-byte by myself but are there any
more efficient and ellegant ways? I tried to use ResXResourceWriter class
but it stores the whole ResX file and what I need is only the text-encoded
binary data (i.e. the content of /data/value from such ResX).

It's fairly simple to write a base 64 encoder/decoder. However, you
could also potentially use XmlWriter.WriteBase64 and
XmlTextReader.ReadBase64 if you're using those classes.
 
Back
Top