954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Storing A Long Array of bytes in an XML file.

Hey all,

I got this problem regarding storing array of bytes (Length=589824) inside an XML document.

i tried using a memory stream and it did not work.
i also tried the following lines of code:

System.Text.Encoding.UTF8.GetString(Memory Stream.ToArray());
System.Text.Encoding.UTF8.GetString(byte[]);

the result was an empty string resulting inside the XML.

NOTE: i tried the above functions on a smaller array of bytes (length = 54) and it worked.

so please anyone who has the answer i will appreciate it.

thanks

khusani
Newbie Poster
13 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

Need more info.

I assume (hah) you are using List. This would make it so much easier for you.

List<byte> mybytes = new List<byte>();
mybytes.add(dabyte);

You can then lay down the foreach

DataTable dt = new DataTable();
dt.Columns.Add("dabyte", byte);

foreach (byte b in mybytes)
{
dt.Rows.Add(object[] {b})
}

dt.WriteXML("C:\dabytes.xml");
Venjense
Light Poster
31 posts since Oct 2003
Reputation Points: 13
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You