I want to write a MemoryStream to a buffer.
I use the codes below;
The code is from the msdn help,
They always declare the size of buffer as the (length of memorystream)+1;
The code run ok, but if I declare the size of buffer as the (length of
memorystream),
it run ok too.
How to determinate the size of buffer of memorystream?
//
Code---------------------------------------------------------------------------------------------------
DataSet ds = Will.DM.ExecuteDataset("Select * from customer");
MemoryStream ms1 = new MemoryStream();
ds.WriteXml(ms1);
DataSet ds2 = new DataSet();
int iLen = (int)ms1.Length;
byte[] buffer1 = new byte[iLen+1];
ms1.Position = 0;
ms1.Read(buffer1, 0, iLen);