Need help understanding Stream.Read()
I am a little confused as to the steps of reading a file into buffer gradually. from the MSDN docs public abstract int Read( byte[] buffer, int offset, int count ) source from C# Examples FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read); try { int length = (int)fileStream.Length; // get file length buffer = new byte[length]; // create buffer int count; // actual number of bytes read int sum = 0; // total number of bytes read // read until Read method returns 0 (end of the stream has been reached) while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)