- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
public static byte[] ConvertToMessage(Stream stream)
{
int length = (int) stream.Length;
byte[] buffer = new byte[length + 4];
buffer[0] = (byte) (length & 0xff);
buffer[1] = (byte) ((length & 0xff00) >> 8);
buffer[2] = (byte) ((length & 0xff0000) >> 16);
buffer[3] = (byte) ((length & 0xff000000L) >> 24);
stream.Read(buffer, 4, length);
return buffer;
}