网上的代码



                contentBytes[2] = (byte)(temp.Length & 0xFF);

                contentBytes[3] = (byte)(temp.Length >> 8 & 0xFF);

替换为:


            else if (temp.Length < 0xFFFF)
            {
                contentBytes = new byte[temp.Length + 4];
                contentBytes[0] = 0x81;
                contentBytes[1] = 126;
                contentBytes[2] = (byte)(temp.Length >> 8 & 0xFF);
                contentBytes[3] = (byte)(temp.Length & 0xFF);
                Array.Copy(temp, 0, contentBytes, 4, temp.Length);
            }
                contentBytes[3] = (byte)(temp.Length & 0xFF);

本文转载:CSDN博客