- 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;
}
bormand 19.10.2012 19:09 # +1
akaDElpher 23.10.2012 10:43 # +1
http://msdn.microsoft.com/en-us/library/system.io.stream.beginread.aspx