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

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");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.