From 7636d8c3784b871ecbed576348e3bec9e904c524 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Wed, 16 Nov 2022 18:37:19 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArmoredCar/ArmoredCar/MapsCollection.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ArmoredCar/ArmoredCar/MapsCollection.cs b/ArmoredCar/ArmoredCar/MapsCollection.cs index 0bd5205..19195c8 100644 --- a/ArmoredCar/ArmoredCar/MapsCollection.cs +++ b/ArmoredCar/ArmoredCar/MapsCollection.cs @@ -89,13 +89,14 @@ namespace ArmoredCar { File.Delete(filename); } - using (StreamWriter fs = new(filename)) + using (FileStream f = new FileStream(filename, FileMode.Create)) + using (StreamWriter sw = new StreamWriter(f, Encoding.UTF8)) { - fs.WriteLine("MapsCollection"); + sw.WriteLine("MapsCollection"); foreach (var storage in _mapStorages) { - fs.WriteLine($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}"); + sw.WriteLine($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}"); } } return true; @@ -110,15 +111,16 @@ namespace ArmoredCar if (!File.Exists(filename)) { return false; - } - using (StreamReader fs = new(filename)) + } + using (FileStream f = new(filename, FileMode.Open)) + using (StreamReader sw = new(f, Encoding.UTF8)) { - if (!fs.ReadLine().Contains("MapsCollection")) + if (!sw.ReadLine().Contains("MapsCollection")) return false; string? line; _mapStorages.Clear(); - while ((line = fs.ReadLine()) != null) + while ((line = sw.ReadLine()) != null) { var elem = line.Split(separatorDict); AbstractMap map = null;