Переписал сохранение на StreamWriter
This commit is contained in:
parent
262ac5cd8c
commit
ca9860ba86
@ -89,23 +89,20 @@ namespace ProjectStormtrooper
|
||||
{
|
||||
File.Delete(filename);
|
||||
}
|
||||
StringBuilder data = new();
|
||||
foreach (KeyValuePair<string, PlanesGenericCollection<DrawingPlane, DrawingObjectPlane>> record in _planeStorages)
|
||||
using (StreamWriter sw = File.CreateText(filename))
|
||||
{
|
||||
StringBuilder records = new();
|
||||
foreach (DrawingPlane? elem in record.Value.GetPlanes)
|
||||
sw.WriteLine($"PlaneStorage");
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user