Переписал сохранение на StreamWriter
This commit is contained in:
parent
262ac5cd8c
commit
ca9860ba86
@ -89,23 +89,20 @@ namespace ProjectStormtrooper
|
|||||||
{
|
{
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
}
|
}
|
||||||
StringBuilder data = new();
|
using (StreamWriter sw = File.CreateText(filename))
|
||||||
foreach (KeyValuePair<string, PlanesGenericCollection<DrawingPlane, DrawingObjectPlane>> record in _planeStorages)
|
|
||||||
{
|
{
|
||||||
StringBuilder records = new();
|
sw.WriteLine($"PlaneStorage");
|
||||||
foreach (DrawingPlane? elem in record.Value.GetPlanes)
|
string storageString;
|
||||||
|
foreach (var storage in _planeStorages)
|
||||||
{
|
{
|
||||||
records.Append($"{elem?.GetDataForSave(_separatorForObject)}{_separatorRecords}");
|
storageString = "";
|
||||||
|
foreach (var plane in storage.Value.GetPlanes)
|
||||||
|
{
|
||||||
|
storageString += $"{plane?.GetDataForSave(_separatorForObject)}{_separatorRecords}";
|
||||||
|
}
|
||||||
|
sw.WriteLine($"{storage.Key}{_separatorForKeyValue}{storageString}");
|
||||||
}
|
}
|
||||||
data.AppendLine($"{record.Key}{_separatorForKeyValue}{records}");
|
|
||||||
}
|
}
|
||||||
if (data.Length == 0)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
using FileStream fs = new(filename, FileMode.Create);
|
|
||||||
byte[] info = new UTF8Encoding(true).GetBytes($"PlaneStorage{Environment.NewLine}{data}");
|
|
||||||
fs.Write(info, 0, info.Length);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user