PIbd-14 Antonova_A.A. LabWork06 Simple #6
@ -156,30 +156,21 @@ public class StorageCollection<T>
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string bufferTextFromFile = "";
|
||||
using (FileStream fs = new(filename, FileMode.Open))
|
||||
{
|
||||
byte[] b = new byte[fs.Length];
|
||||
UTF8Encoding temp = new(true);
|
||||
while (fs.Read(b, 0, b.Length) > 0)
|
||||
{
|
||||
bufferTextFromFile += temp.GetString(b);
|
||||
}
|
||||
}
|
||||
string[] strs = bufferTextFromFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (strs == null || strs.Length == 0)
|
||||
using StreamReader rd = new StreamReader(filename);
|
||||
|
||||
|
||||
UTF8Encoding temp = new(true);
|
||||
string str = rd.ReadLine();
|
||||
if (str == null || !str.StartsWith(_collectionKey))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!strs[0].Equals(_collectionKey))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
return false;
|
||||
}
|
||||
|
||||
_storages.Clear();
|
||||
foreach (string data in strs)
|
||||
string strs = "";
|
||||
while ((strs = rd.ReadLine()) != null)
|
||||
{
|
||||
string[] record = data.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
string[] record = strs.Split(_separatorForKeyValue, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (record.Length != 4)
|
||||
{
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user