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

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

            this.smbData.ByteCount = packet.SmbData.ByteCount;
            this.smbData.BufferFormat1 = packet.SmbData.BufferFormat1;

            if (packet.smbData.FileName != null)
            {
                this.smbData.FileName = new byte[packet.smbData.FileName.Length];
                Array.Copy(packet.smbData.FileName, this.smbData.FileName, packet.smbData.FileName.Length);
            }
            else
            {
                this.smbData.FileName = new byte[0];
            }
            this.smbData.BufferFormat2 = packet.SmbData.BufferFormat2;
            this.smbData.ResumeKeyLength = packet.SmbData.ResumeKeyLength;
            this.smbData.ResumeKey = packet.SmbData.ResumeKey;
        }
        /// <summary>
        /// Deep copy constructor.
        /// </summary>
        public SmbFindCloseRequestPacket(SmbFindCloseRequestPacket packet)
            : base(packet)
        {
            this.InitDefaultValue();

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

            this.smbData.ByteCount     = packet.SmbData.ByteCount;
            this.smbData.BufferFormat1 = packet.SmbData.BufferFormat1;

            if (packet.smbData.FileName != null)
            {
                this.smbData.FileName = new byte[packet.smbData.FileName.Length];
                Array.Copy(packet.smbData.FileName, this.smbData.FileName, packet.smbData.FileName.Length);
            }
            else
            {
                this.smbData.FileName = new byte[0];
            }
            this.smbData.BufferFormat2   = packet.SmbData.BufferFormat2;
            this.smbData.ResumeKeyLength = packet.SmbData.ResumeKeyLength;
            this.smbData.ResumeKey       = packet.SmbData.ResumeKey;
        }
        /// <summary>
        /// to create a FindClose 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="fileName">A NUL-terminated SMB_STRING. This MUST be the empty string.</param>
        /// <param name="resumeKey">This MUST be the last ResumeKey returned by the server in the search being
        /// closed.</param>
        /// <returns>a FindClose request packet</returns>
        public SmbFindCloseRequestPacket CreateFindCloseRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            string fileName,
            SMB_Resume_Key resumeKey)
        {
            if (fileName == null)
            {
                fileName = string.Empty;
            }

            SmbFindCloseRequestPacket packet = new SmbFindCloseRequestPacket();

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

            SMB_COM_FIND_CLOSE_Request_SMB_Parameters smbParameters = new SMB_COM_FIND_CLOSE_Request_SMB_Parameters();
            smbParameters.MaxCount = 0;
            smbParameters.SearchAttributes = 0;
            smbParameters.WordCount = (byte)(Marshal.SizeOf(smbParameters) / NumBytesOfWord);

            SMB_COM_FIND_CLOSE_Request_SMB_Data smbData = new SMB_COM_FIND_CLOSE_Request_SMB_Data();
            smbData.BufferFormat1 = (byte)DataBufferFormat.SmbString;
            smbData.FileName = CifsMessageUtils.ToSmbStringBytes(fileName,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);
            smbData.BufferFormat2 = (byte)DataBufferFormat.VariableBlock;
            smbData.ResumeKey = resumeKey;
            smbData.ResumeKeyLength = (ushort)CifsMessageUtils.GetSize<SMB_Resume_Key>(smbData.ResumeKey);
            smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.BufferFormat1) + Marshal.SizeOf(smbData.BufferFormat2)
                + Marshal.SizeOf(smbData.ResumeKeyLength) + CifsMessageUtils.GetSize<SMB_Resume_Key>(smbData.ResumeKey)
                + smbData.FileName.Length);

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

            return packet;
        }
        public SmbFindCloseResponsePacket CreateFindCloseResponse(
            CifsServerPerConnection connection,
            SmbFindCloseRequestPacket request)
        {
            SmbFindCloseResponsePacket response = new SmbFindCloseResponsePacket();
            response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);

            SMB_COM_FIND_CLOSE_Response_SMB_Parameters smbParameters = response.SmbParameters;
            smbParameters.Count = 0x00;
            smbParameters.WordCount = (byte)(TypeMarshal.GetBlockMemorySize(smbParameters) / 2);
            response.SmbParameters = smbParameters;

            SMB_COM_FIND_CLOSE_Response_SMB_Data smbData = response.SmbData;
            smbData.BufferFormat = 0x05;
            smbData.DataLength = 0x0000;
            smbData.ByteCount = 0x0003;
            response.SmbData = smbData;

            return response;
        }