public static void SavePathToATextFile(Path3D path) { using (var writer = new StreamWriter("../../path.txt")) { writer.WriteLine(path.ToString()); } }
static void Main(string[] args) { try { Point3D point1 = new Point3D(0, 5, 1); Point3D point2 = new Point3D(-3, 20, 0); Path3D path = new Path3D(point1, point2); Storage.SavePathToFile("../../path.txt", path.ToString()); Console.WriteLine("Load from file:\n" + Storage.LoadPathFromFile("../../path.txt")); } catch (Exception) { throw; } }
static void Main(string[] args) { try { Point3D point1 = new Point3D(0, 5, 1); Point3D point2 = new Point3D(-3, 20, 0); Path3D path = new Path3D(point1, point2); Storage.SavePathToFile("../../path.txt", path.ToString()); Console.WriteLine("Load from file:\n" + Storage.LoadPathFromFile("../../path.txt")); } catch (Exception) { throw; } }
static void Main() { try { Point3D point1 = new Point3D(1, 5, 24); Point3D point2 = new Point3D(0, -12, 3); Point3D point3 = new Point3D(1, 5, 3); Path3D path = new Path3D(point1, point2, point3); Console.WriteLine(path); Storage.SavePathToFile("../../path.txt", path.ToString()); Console.WriteLine("Load from file:\n" + Storage.LoadPathFromFile("../../path.txt")); } catch (FileNotFoundException) { Console.Error.WriteLine("Can not find file!"); } catch (IOException) { Console.Error.WriteLine("Can not open the file!"); } }
public static void Save(Path3D path) { File.WriteAllText(FilePath, path.ToString()); Console.WriteLine("File ({0}) saved.", FileName); }