FileStream, , HttpWebRequest.
FileStream.Read can theoretically return 1 byte. You should still process this small package.
But it will never return 0 unless there is a problem related to disconnecting the SMB connection, deleting the file, antivirus or getting to the end of the file.
There are better ways to read files. If you are dealing with a text file, use System.IO.StreamReader instead, as it handles various text encoding, line breaks, etc.
Also keep in mind that the maximum buffer size is 2 GB, so don't new buffer[fileStream.Length]
source
share