static void Main(string[] args) { Path3D myPath3D = new Path3D(new Point3D(-5, 55, 444), new Point3D(44, -5, 77), new Point3D(10, 20, 30), new Point3D(47, 74, -4)); myPath3D.AddPoint(new Point3D(21, 45, -4)); myPath3D.AddPoint(new Point3D(-5, -7, -55)); myPath3D.AddPoint(new Point3D(45, 54, 77)); Storage.SavePath(myPath3D); Path3D newPath3D = Storage.LoadPath3D("ExistPath.txt"); }
public static Path3D LoadPath3D(string fileName) { Path3D path = new Path3D(); string fileNamePath = string.Format("{0}{1}", "../../", fileName); if (File.Exists(fileNamePath)) { using (var reader = new StreamReader(fileNamePath)) { string line = reader.ReadLine(); while (line != null) { double[] coordinates = line.Split(new char[] {'{', '}', ',', ' '}, StringSplitOptions.RemoveEmptyEntries) .Select(double.Parse) .ToArray(); path.AddPoint(new Point3D(coordinates[0], coordinates[1], coordinates[2])); line = reader.ReadLine(); } } } else { Console.WriteLine("The source file not found."); path = null; } return path; }