public static Path3D LoadPath(string fileName) { List <Point3D> points = new List <Point3D>(); Path3D path; try { StreamReader streamReader = new StreamReader(fileName); using (streamReader) { String line = streamReader.ReadLine(); while (line != null) { double[] coordinates = PointExtractor(line); Point3D point = new Point3D(coordinates[0], coordinates[1], coordinates[2]); points.Add(point); line = streamReader.ReadLine(); } } } catch (Exception exception) { Console.WriteLine(exception.Message); } path = new Path3D(points); return(path); }
static void Main(string[] args) { Point3D firstPoint = new Point3D(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine())); Point3D secondPoint = new Point3D(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine())); Point3D thirdPoint = new Point3D(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine())); List <Point3D> firstPointList = new List <Point3D> { firstPoint, secondPoint, thirdPoint }; List <Point3D> secondPointList = new List <Point3D> { secondPoint, thirdPoint }; List <Point3D> thridPointList = new List <Point3D> { firstPoint, thirdPoint }; Path3D firstPath = new Path3D(firstPointList); Path3D secondPath = new Path3D(secondPointList); Path3D thirdPath = new Path3D(thridPointList); Storage.SavePath(@"C:\Users\Nikolay\Documents\Visual Studio 2013\Projects\StaticMembersAndNamespaces\_3_Paths\newSample"); Path3D newPath = Storage.LoadPath(@"../../loadSample.txt"); Storage.SavePath(@"C:\Users\Nikolay\Documents\Visual Studio 2013\Projects\StaticMembersAndNamespaces\_3_Paths\newSample"); Console.WriteLine(newPath); }