public Packet(BinaryReader reader) { opcode = reader.ReadByte(); Logger.Log("Packet: received packet, opcode " + opcode); int length = Packet.GetInputPacketLength(opcode); data = reader.ReadBytes(length); packetCounter++; // per-packet logging FileStream fs = File.Open("packet" + packetCounter.ToString().PadLeft(5, '0') + ".dat", FileMode.Create); BinaryWriter bw = new BinaryWriter(fs); bw.Write(data); bw.Close(); }