Исправление

This commit is contained in:
prodigygirl 2022-11-16 18:37:19 +04:00
parent 3b328133e6
commit 7636d8c378

View File

@ -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;