net读取文件字节流要注意的小细节

时间:2021-05-10 03:30:17
            var bytes = new byte[fileLenght+];
var numBytesToRead = (int)fileLenght;
var numBytesRead = ;
using (fs)
{
do
{
int n = fs.Read(bytes, numBytesRead, );
numBytesRead += n;
numBytesToRead -= n; } while (numBytesToRead > ); fs.Close();
}

https://docs.microsoft.com/zh-cn/dotnet/api/system.io.stream.read?redirectedfrom=MSDN&view=netframework-4.7.2#System_IO_Stream_Read_System_Byte___System_Int32_System_Int32_

http://www.cnblogs.com/JimmyZheng/archive/2012/03/17/2402814.html