This will serialize a point[] array pretty much just as you have into a
memory stream, then deserialize it back into a point array.
{
Point[] ptArray = { new Point(1,1), new Point (2,2), new Point(3,3)};
//Or Point[] ptArray = (Point[])_allLines.ToArray(typeof(Point))
System.IO.MemoryStream ms = new System.IO.MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(ms, ptArray);
ptArray = null;
//Deserialize:
ms.Seek(0, System.IO.SeekOrigin.Begin);
ptArray = (Point[])formatter.Deserialize(ms);
}
--
-Philip Rieck
http://philiprieck.com/blog/
-
"TJO" <no@spam.com> wrote in message
news:O5**************@TK2MSFTNGP10.phx.gbl...
I need a quick way to binary serialize an ArrayList of System.Drawing.Point
objects. There are a lot of point is this list so I am trying to avoid
iterating over them. I have tried the following but cannot find an easy
way
to Deserialize the data. Can anyone suggest a better way?
Array ptArray = _allLines.ToArray(typeof(System.Drawing.Point));
System.IO.MemoryStream ms = new System.IO.MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(ms,ptArray);
return ms.GetBuffer();