diff --git a/Lab1ContainersShip/Lab1ContainersShip/ShipGenericStorage.cs b/Lab1ContainersShip/Lab1ContainersShip/ShipGenericStorage.cs index f269f64..420cd15 100644 --- a/Lab1ContainersShip/Lab1ContainersShip/ShipGenericStorage.cs +++ b/Lab1ContainersShip/Lab1ContainersShip/ShipGenericStorage.cs @@ -190,5 +190,28 @@ public bool SaveData(string filename) } return true; } + public bool SaveDop(string filename, string key) + { + if (File.Exists(filename)) + { + File.Delete(filename); + } + StringBuilder data = new StringBuilder(); + ShipGenericCollection record = _shipStorages[key]; + if (!_shipStorages.ContainsKey(key)) + { + return false; + } + if(record != null) + { + using (StreamWriter sr = new StreamWriter(filename)) + { + sr.Write(filename + " "); + sr.WriteLine(record); + return true; + } + } + return false; + } } }