// Load path Method public static List<Path> LoadPaths() { Path newPath = new Path(); List<Path> listOfPaths = new List<Path>(); StreamReader reader = new StreamReader("../../LoadPoints.txt"); using (reader) { string line = reader.ReadLine(); while (line != null) { if (line != "end") { Point3D point = new Point3D(); string[] points = line.Split(','); point.x = int.Parse(points[0]); point.y = int.Parse(points[1]); point.z = int.Parse(points[2]); newPath.AddPointInList(point); } else { listOfPaths.Add(newPath); newPath = new Path(); } line = reader.ReadLine(); } } return listOfPaths; }
static void Main(string[] args) { Point3D a = new Point3D(1, 1, 1); Point3D b = new Point3D(2, 2, 2); //Console.WriteLine(PointDistance.Distance(a, b)); // Saving list of points in a text file Path file = new Path(); file.AddPointInList(a); file.AddPointInList(b); PathStorage.SavePaths(file); // Loading list of points from a text file List<Path> listOfPaths = PathStorage.LoadPaths(); foreach (var path in listOfPaths) { Console.WriteLine("Point List:"); foreach (var point in path.ListOfPoints) { Console.WriteLine(point); } } }