protected override void ReadData() { try { using (var input = new FileStream(InputFile, FileMode.Open, FileAccess.Read)) { var lenght = input.Length; int readCount; byte[] bytes; while (input.Position < lenght && !IsError) { if (lenght - input.Position < BlockSize) { readCount = (int)(lenght - input.Position); } else { readCount = BlockSize; } bytes = new byte[readCount]; input.Read(bytes, 0, readCount); //добавим доп инф. о позиции массива байт в файле и размере файла bytes = AddedHelpersData(input.Position - readCount, lenght, bytes); BlockReaded.AddBlock(new BlockData(bytes)); } BlockReaded.Finish(); } } catch (OutOfMemoryException e) { ErrorOutput(e, "Not enough RAM to complete file read. Please close other applications and try again. "); } catch (Exception e) { ErrorOutput(e); } finally { EventWaitHandleRead.Set(); } }
protected override void ReadData() { try { using (var input = new FileStream(InputFile, FileMode.Open, FileAccess.Read)) { byte[] headerGzip; byte[] bytes; int lenghtBlock; while (input.Position < input.Length && !IsError) { //читаем заголовок запакованного блока и получаем размер полезной нагрузки указанной при записи headerGzip = new byte[8]; input.Read(headerGzip, 0, headerGzip.Length); lenghtBlock = BitConverter.ToInt32(headerGzip, 4); bytes = new byte[lenghtBlock]; headerGzip.CopyTo(bytes, 0); input.Read(bytes, headerGzip.Length, lenghtBlock - headerGzip.Length); BlockReaded.AddBlock(new BlockData(bytes)); } BlockReaded.Finish(); EventWaitHandleRead.Set(); } } catch (OutOfMemoryException e) { ErrorOutput(e, "Not enough RAM to complete file read. Please close other applications and try again. "); } catch (Exception e) { ErrorOutput(e); } finally { EventWaitHandleRead.Set(); } }