1 byte[] buffer = new byte[BufferSize]; 2 int bytesRead; // 读取的字节数 3 MemoryStream msStream = new MemoryStream(); 4 do { 5 bytesRead = streamToClient.Read(buffer, 0, BufferSize); 6 msStream.Write(buffer, 0, bytesRead); 7 } while (bytesRead > 0); 8 9 buffer = msStream.GetBuffer();