public static void Main() { Path3D testPath = new Path3D(); testPath.AddPoint(0, 3.78, 5); testPath.AddPoint(7, 3, 1); testPath.AddPoint(9, 4, 1); Storage.Save3DPointsPath(testPath, "SavedPoint.txt"); Path3D newPath = Storage.Load3DPointsPath("SavedPoint.txt"); Console.WriteLine(newPath[0]); }
public static Path3D Load3DPointsPath(string path) { Path3D listofpoints = new Path3D(); using (StreamReader reader = new StreamReader(path)) { string line; Regex regex = new Regex(@"(\d+|\d+\.\d+)\,\s*(\d+|\d+\.\d+)\,\s*(\d+|\d+\.\d+)"); while ((line = reader.ReadLine()) != null) { var v = regex.Match(line); double x = double.Parse(v.Groups[1].Value); double y = double.Parse(v.Groups[2].Value); double z = double.Parse(v.Groups[3].Value); listofpoints.AddPoint(x, y, z); // Add to list. Console.WriteLine(line); // Write to console. } } return listofpoints; }