| .NET DotNet Forum Index » Visual C# Forum » Can I save Byte[] in a XML file?... |
|
Page 1 of 1 |
|
| Author |
Message |
| shapper... |
Posted: Sun Nov 01, 2009 2:28 pm |
|
|
|
Guest
|
Hello,
Can I save binary data into a XML file?
Basically I need to save a Byte[] to a XML and retrieve it later.
Maybe by converting the Byte[] to Base64 String when saving?
.... and converting it back to Byte[] when retrieving the data?
Thanks,
Miguel |
|
|
| Back to top |
|
|
|
| shapper... |
Posted: Sun Nov 01, 2009 2:53 pm |
|
|
|
Guest
|
On Nov 2, 12:37 am, Peter Duniho <no.peted.s... at (no spam) no.nwlink.spam.com>
wrote:
Quote: shapper wrote:
Hello,
Can I save binary data into a XML file?
You can save anything that you can represent as text in an XML file.
Since you can represent binary data as text, you can save it in an XML file.
Basically I need to save a Byte[] to a XML and retrieve it later.
Maybe by converting the Byte[] to Base64 String when saving?
.... and converting it back to Byte[] when retrieving the data?
Yes, Base64 is a fairly common way of encoding binary data so that it
can be saved in an XML file.
Pete
Thank you Pete. |
|
|
| Back to top |
|
|
|
| Peter Duniho... |
Posted: Sun Nov 01, 2009 7:37 pm |
|
|
|
Guest
|
shapper wrote:
Quote: Hello,
Can I save binary data into a XML file?
You can save anything that you can represent as text in an XML file.
Since you can represent binary data as text, you can save it in an XML file.
Quote: Basically I need to save a Byte[] to a XML and retrieve it later.
Maybe by converting the Byte[] to Base64 String when saving?
.... and converting it back to Byte[] when retrieving the data?
Yes, Base64 is a fairly common way of encoding binary data so that it
can be saved in an XML file.
Pete |
|
|
| Back to top |
|
|
|
| Bjørn Brox... |
Posted: Mon Nov 02, 2009 4:23 pm |
|
|
|
Guest
|
shapper skrev:
Quote: Hello,
Can I save binary data into a XML file?
Basically I need to save a Byte[] to a XML and retrieve it later.
Maybe by converting the Byte[] to Base64 String when saving?
... and converting it back to Byte[] when retrieving the data?
Just use XMlSerialize and you don't have to worry on both saving and
reading the data structures. It takes care of proper encoding both of
binary and other data types.
--
Bjørn Brox |
|
|
| Back to top |
|
|
|
|