socket传来bytearry,为什么这样写会丢掉前面1024字节?用2进制查看就是少了前面1024个字节
以下为我的部分代码private void onStreamRead(IAsyncResult ar)
{
            //number of bytes read from the stream
            int bytesRead;            MemoryStream ms = new MemoryStream();
        
            try
            {
                //read the bytes from the stream
                //bytesRead = stream.EndRead(ar);                byte[] buff = new byte[1024];
                
                int size =buff.Length;                do
                {
                    size = stream.Read(buff, 0, 1024);
                    ms.Write(buff, 0, size);
                } while (size == buff.Length);               
                
            }
            catch (Exception r)
            {
                //if anything goes wrong, just return
               // return;
            }            byte[] msarr = ms.ToArray();            using(FileStream fs = new FileStream("d:\\123.png", FileMode.Create, FileAccess.Write)){
               fs.Write(msarr, 0, msarr.Length);
                fs.Close();
            }
            return;
}