/// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbWritePrintFileRequestPacket(SmbWritePrintFileRequestPacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

            this.smbParameters.WordCount = packet.SmbParameters.WordCount;
            this.smbParameters.FID = packet.SmbParameters.FID;

            this.smbData.ByteCount = packet.SmbData.ByteCount;
            this.smbData.BufferFormat = packet.SmbData.BufferFormat;
            this.smbData.DataLength = packet.SmbData.DataLength;
            if (packet.smbData.Data != null)
            {
                this.smbData.Data = new byte[packet.smbData.Data.Length];
                Array.Copy(packet.smbData.Data, this.smbData.Data, packet.smbData.DataLength);
            }
            else
            {
                this.smbData.Data = new byte[0];
            }
        }
        /// <summary>
        /// to create a WritePrintFile request packet.
        /// </summary>
        /// <param name="messageId">This field SHOULD be the multiplex ID that is used to associate a response with a
        /// request.</param>
        /// <param name="uid">This field SHOULD identify the authenticated instance of the user.</param>
        /// <param name="treeId">This field identifies the subdirectory (or tree) on the server that the client is
        /// accessing.</param>
        /// <param name="flags">An 8-bit field of 1-bit flags describing various features in effect for the
        /// message</param>
        /// <param name="flags2">A 16-bit field of 1-bit flags that represent various features in effect for the
        /// message. Unspecified bits are reserved and MUST be zero.</param>
        /// <param name="fid">This field MUST be a valid FID, creating using the SMB_COM_OPEN_PRINT_FILE
        /// command.</param>
        /// <param name="data">Bytes to be written to the spool file indicated by FID.</param>
        /// <returns>a WritePrintFile request packet</returns>
        public SmbWritePrintFileRequestPacket CreateWritePrintFileRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort fid,
            byte[] data)
        {
            if (data == null)
            {
                data = new byte[0];
            }

            SmbWritePrintFileRequestPacket packet = new SmbWritePrintFileRequestPacket();

            packet.SmbHeader = CifsMessageUtils.CreateSmbHeader(SmbCommand.SMB_COM_WRITE_PRINT_FILE,
                messageId, uid, treeId, flags, flags2);

            SMB_COM_WRITE_PRINT_FILE_Request_SMB_Parameters smbParameters =
                new SMB_COM_WRITE_PRINT_FILE_Request_SMB_Parameters();
            smbParameters.FID = fid;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_WRITE_PRINT_FILE_Request_SMB_Data smbData = new SMB_COM_WRITE_PRINT_FILE_Request_SMB_Data();
            smbData.BufferFormat = (byte)DataBufferFormat.DialectString;
            smbData.DataLength = (ushort)data.Length;
            smbData.Data = data;
            smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.BufferFormat) + Marshal.SizeOf(smbData.DataLength)
                + data.Length);

            packet.SmbParameters = smbParameters;
            packet.SmbData = smbData;

            return packet;
        }
        public SmbWritePrintFileResponsePacket CreateWritePrintFileResponse(
            CifsServerPerConnection connection,
            SmbWritePrintFileRequestPacket request)
        {
            SmbWritePrintFileResponsePacket response = new SmbWritePrintFileResponsePacket();
            response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);

            return response;
        }