private static void SavePointArray(string FileName, Point[] PointArray)
{
StreamWriter writer = File.CreateText(FileName);
foreach (Point point in PointArray)
writer.WriteLine(point.ToString());
writer.Dispose();
}
private static readonly char[] RemoveChars = new char[] { '{', '}', '=', 'X', 'Y', ',' };
private static Point[] LoadPointArray(string FileName)
{
StreamReader reader = File.OpenText(FileName);
List<Point> result = new List<Point>();
string line;
string[] chunks;
int x, y;
while (!reader.EndOfStream)
{
line = reader.ReadLine();
chunks = line.Split(RemoveChars, StringSplitOptions.RemoveEmptyEntries);
int.TryParse(chunks[0], out x);
int.TryParse(chunks[1], out y);
result.Add(new Point(x, y));
}
reader.Dispose();
return result.ToArray();
}
You should also do some checking to make sure everything is ok.