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

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

            this.smbData.ByteCount = packet.SmbData.ByteCount;
        }
        /// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbCloseAndTreeDiscRequestPacket(SmbCloseAndTreeDiscRequestPacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

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

            this.smbData.ByteCount = packet.SmbData.ByteCount;
        }
        /// <summary>
        /// to create a CloseAndTreeDisc 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">The FID of the object to be closed</param>
        /// <param name="lastTimeModified">A time value encoded as the number of seconds since January 1, 
        /// 1970 00:00:00.0. The client MAY request that the last modification time for the file be updated to this
        /// time value. A value of 0 or 0xFFFFFF results in the server using the default value. The server is NOT 
        /// REQUIRED to support this request</param>
        /// <returns>a CloseAndTreeDisc request packet</returns>
        public SmbCloseAndTreeDiscRequestPacket CreateCloseAndTreeDiscRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            ushort fid,
            UTime lastTimeModified)
        {
            SmbCloseAndTreeDiscRequestPacket packet = new SmbCloseAndTreeDiscRequestPacket();

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

            SMB_COM_CLOSE_Request_SMB_Parameters smbParameters = new SMB_COM_CLOSE_Request_SMB_Parameters();
            smbParameters.FID = fid;
            smbParameters.LastTimeModified = lastTimeModified;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_CLOSE_Request_SMB_Data smbData = new SMB_COM_CLOSE_Request_SMB_Data();
            smbData.ByteCount = 0;

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

            return packet;
        }
        public SmbCloseAndTreeDiscResponsePacket CreateCloseAndTreeDiscResponse(
            CifsServerPerConnection connection,
            SmbCloseAndTreeDiscRequestPacket request)
        {
            SmbCloseAndTreeDiscResponsePacket response = new SmbCloseAndTreeDiscResponsePacket();
            SmbHeader smbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);

            if ((smbHeader.Flags2 & SmbFlags2.SMB_FLAGS2_NT_STATUS) == SmbFlags2.SMB_FLAGS2_NT_STATUS)
            {
                smbHeader.Status = (uint)NtStatus.STATUS_NOT_IMPLEMENTED;
            }
            else
            {
                SmbStatus smbStatus = new SmbStatus();
                smbStatus.ErrorClass = SmbErrorClass.ERRDOS;
                smbStatus.Reserved = 0;
                smbStatus.ErrorCode = (ushort)SmbErrorCodeOfERRDOS.ERRbadfunc;
                smbHeader.Status = smbStatus;
            }
            response.SmbHeader = smbHeader;

            return response;
        }