0
我正在使用MRIM(Mail.Ru代理程序)協議。 MRIM是一種二進制協議,所以爲了製作數據二進制文件,我使用了BinaryWriter類。下面的代碼:二進制Writer返回null的字節數組
private byte[] CreateMrimPacket(ulong message)
{
byte[] binaryData;
using (MemoryStream ms = new MemoryStream())
{
using (BinaryWriter bw = new BinaryWriter(ms))
{
bw.Write(CS_MAGIC); //CS_MAGIC is a constant that doesn't equal 0
bw.Write(PROTO_VERSION); //Same thing
bw.Write((ulong)SeqCounter);
bw.Write(message);
bw.Write((ulong)0);
bw.Write((ulong)0);
bw.Write((ulong)0);
bw.Write((ulong)0);
bw.Write((ulong)0);
bw.Write((ulong)0);
bw.Write((ulong)0);
binaryData = new byte[ms.Length];
ms.Read(binaryData, 0, binaryData.Length);
}
}
return binaryData;
}
該函數返回字節數組,但所有的值都爲0。
請幫我解決這個問題。
在此先感謝
非常感謝!現在一切正常! – Cracker