I'm quite new to C# so please bear with me. I'm reading (using FileStream) data (fixed size) to small array, process the data and then read again and so on to the end of file.
I thought about using something like this:
byte[] data = new byte[30];
int numBytesToRead = (int)fStream.Length;
int offset = 0;
//reading
while (numBytesToRead > 0)
{
fStream.Read(data, offset, 30);
offset += 30;
numBytesToRead -= 30;
//do something with the data
}
But I checked documentation and their examples and they stated that return value of the above read method is:
"Type: System.Int32 The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached."
What does it mean that they are not currently available, can this really happen when reading small amounts of data or is this just for large amounts? If only for large, how large approximately, because I'll be reading also in bigger chunks in some other places. If this can happen anytime how should I change my code so that the code will still execute efficiently?
Thank you for your time and answers.