From d0e1ba40244bb1800eb37d73ebf8ab4d6613f274 Mon Sep 17 00:00:00 2001 From: AnnaLioness Date: Fri, 1 Dec 2023 15:28:29 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BF=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Lab1ContainersShip/ShipGenericStorage.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) 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; + } } }