Good day to all, faced with a problem
Reading after the end of the stream is not possible.
The fact is that I am reading a binary file:
while (reader2.PeekChar() > -1) { numb2 = reader2.ReadInt32(); Int32 ndef2 = reader2.ReadInt32(); BitVector32 bv2 = new BitVector32(ndef); int nr2 = bv2[nr_s]; y2 = bv2[y_s]; int sm2 = bv2[sm_s]; ds2 = bv2[d_s]; ms2 = bv2[m_s]; int rs2 = bv2[r_s]; } And it so happened that numb2 has an entry in the file therefore reader2.PeekChar() > -1 greater than 1, but ndef2 is no longer in the file, and I get a read error after the end of the stream, maybe there is a more correct method for initializing data in the file, and if there is no further record, then just pass 0 and go on, or skip and go on, just do not want to do something like:
while (reader2.PeekChar() > -1) { numb2 = reader2.ReadInt32(); if (reader2.PeekChar() > -1){ Int32 ndef2 = reader2.ReadInt32(); BitVector32 bv2 = new BitVector32(ndef); int nr2 = bv2[nr_s]; y2 = bv2[y_s]; int sm2 = bv2[sm_s]; ds2 = bv2[d_s]; ms2 = bv2[m_s]; int rs2 = bv2[r_s]; } } Or will you still have to put another check, as I wrote above?
Please help me figure it out.
numb2Yes, I could do this, for example, put the number of bytes in the buffer and then read them throughRead, but my file is appended every time and I cannot know its exact length, I can only know that there arenumb2values and everything andndef2mayndef2may not have information. - Ethernets