lab_6(storage)
This commit is contained in:
parent
e9d5335db9
commit
51f2664d20
@ -80,10 +80,11 @@ namespace speed_Boat.Generics
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
using FileStream fs = new(filename, FileMode.Create);
|
|
||||||
byte[] info = new
|
using (StreamWriter sw = new (filename))
|
||||||
UTF8Encoding(true).GetBytes($"BoatStorage{Environment.NewLine}{data}");
|
{
|
||||||
fs.Write(info, 0, info.Length);
|
sw.WriteLine($"BoatStorage{Environment.NewLine}{data}");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -98,17 +99,10 @@ namespace speed_Boat.Generics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string bufferTextFromFile = "";
|
string bufferTextFromFile = "";
|
||||||
using (FileStream fs = new(filename, FileMode.Open))
|
using (StreamReader sr = new(filename))
|
||||||
{
|
{
|
||||||
byte[] b = new byte[fs.Length];
|
string str = sr.ReadLine();
|
||||||
UTF8Encoding temp = new(true);
|
var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
while (fs.Read(b, 0, b.Length) > 0)
|
|
||||||
{
|
|
||||||
bufferTextFromFile += temp.GetString(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var strs = bufferTextFromFile.Split(new char[] { '\n', '\r' },
|
|
||||||
StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (strs == null || strs.Length == 0)
|
if (strs == null || strs.Length == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -119,12 +113,13 @@ namespace speed_Boat.Generics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_boatStorages.Clear();
|
_boatStorages.Clear();
|
||||||
foreach (string data in strs)
|
do
|
||||||
{
|
{
|
||||||
string[] record = data.Split(_separatorForKeyValue,
|
string[] record = str.Split(_separatorForKeyValue,
|
||||||
StringSplitOptions.RemoveEmptyEntries);
|
StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (record.Length != 2)
|
if (record.Length != 2)
|
||||||
{
|
{
|
||||||
|
str = sr.ReadLine();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BoatsGenericCollection<DrawingBoat, DrawingObjectBoat>
|
BoatsGenericCollection<DrawingBoat, DrawingObjectBoat>
|
||||||
@ -142,6 +137,8 @@ namespace speed_Boat.Generics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
_boatStorages.Add(record[0], collection);
|
_boatStorages.Add(record[0], collection);
|
||||||
|
str = sr.ReadLine();
|
||||||
|
} while (str != null);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user