S
Simon Hart
Sounds an easy task and should be, but the code result is a blank byte
array.
Comments within code.
The code is:
Stream sr = new MemoryStream();
XmlSerializer s = new XmlSerializer(typeof(CRM.BusinessEntity));
s.Serialize(sr, response.BusinessEntity);
//MemoryStream does contain correct byte array after the above.
byte[] serBuf = new byte[(int)sr.Length - 1];
sr.Read(serBuf, 0, serBuf.Length - 1);
sr.Close(); //Close the stream to release the memory.
//At this point serBuf is never set with the byte array held in the
MemoryStream!
//Now we want to convert the array of bytes to a string.
//We do this by using the Encoding class.
string myData = System.Text.Encoding.ASCII.GetString(serBuf);
Any help would be great.
Simon.
array.
Comments within code.
The code is:
Stream sr = new MemoryStream();
XmlSerializer s = new XmlSerializer(typeof(CRM.BusinessEntity));
s.Serialize(sr, response.BusinessEntity);
//MemoryStream does contain correct byte array after the above.
byte[] serBuf = new byte[(int)sr.Length - 1];
sr.Read(serBuf, 0, serBuf.Length - 1);
sr.Close(); //Close the stream to release the memory.
//At this point serBuf is never set with the byte array held in the
MemoryStream!
//Now we want to convert the array of bytes to a string.
//We do this by using the Encoding class.
string myData = System.Text.Encoding.ASCII.GetString(serBuf);
Any help would be great.
Simon.