public void Save()
{
Point[] pt = {new Point(-10,2), new Point(-9,24), new Point(-8,45)};
string filePath = @"D:\Point.txt";
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(filePath))
{
for (int i = 0; i < pt.Length; i++)
{
sw.Write(pt[i].X);
sw.Write(",");
sw.Write(pt[i].Y);
sw.Write(" ");
}
}
}
public void Load()
{
string filePath = @"D:\Point.txt";
using (System.IO.StreamReader sr = new System.IO.StreamReader(filePath))
{
string str = sr.ReadToEnd();
string[] ss = str.Split(new char[] { ' ', ',' });
int ptCount = ss.Length / 2;
Point[] pt = new Point[ptCount];
for (int i = 0; i < ptCount; i++)
{
pt[i].X = System.Convert.ToInt32(ss[2*i]);
pt[i].Y = System.Convert.ToInt32(ss[2 * i + 1]);
}
}
}