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

            this.smbParameters.WordCount = packet.SmbParameters.WordCount;
            this.smbData.ByteCount = packet.SmbData.ByteCount;
            this.smbData.BufferFormat = packet.SmbData.BufferFormat;

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

            this.smbParameters.WordCount = packet.SmbParameters.WordCount;
            this.smbData.ByteCount       = packet.SmbData.ByteCount;
            this.smbData.BufferFormat    = packet.SmbData.BufferFormat;

            if (packet.smbData.DirectoryName != null)
            {
                this.smbData.DirectoryName = new byte[packet.smbData.DirectoryName.Length];
                Array.Copy(packet.smbData.DirectoryName,
                           this.smbData.DirectoryName, packet.smbData.DirectoryName.Length);
            }
            else
            {
                this.smbData.DirectoryName = new byte[0];
            }
        }
        /// <summary>
        /// to create a DeleteDirectory 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="directoryName">A null-terminated string that contains the full pathname, relative to the 
        /// supplied TID, of the directory to be deleted.</param>
        /// <returns>the DeleteDirectory request packet.</returns>
        public SmbDeleteDirectoryRequestPacket CreateDeleteDirectoryRequest(
            ushort messageId,
            ushort uid,
            ushort treeId,
            SmbFlags flags,
            SmbFlags2 flags2,
            string directoryName)
        {
            if (directoryName == null)
            {
                directoryName = string.Empty;
            }

            SmbDeleteDirectoryRequestPacket packet = new SmbDeleteDirectoryRequestPacket();

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

            SMB_COM_DELETE_DIRECTORY_Request_SMB_Parameters smbParameters =
                new SMB_COM_DELETE_DIRECTORY_Request_SMB_Parameters();
            smbParameters.WordCount = 0;

            SMB_COM_DELETE_DIRECTORY_Request_SMB_Data smbData = new SMB_COM_DELETE_DIRECTORY_Request_SMB_Data();
            smbData.BufferFormat = (byte)DataBufferFormat.SmbString;
            smbData.DirectoryName = CifsMessageUtils.ToSmbStringBytes(directoryName,
                (flags2 & SmbFlags2.SMB_FLAGS2_UNICODE) == SmbFlags2.SMB_FLAGS2_UNICODE);
            smbData.ByteCount = (ushort)(Marshal.SizeOf(smbData.BufferFormat) + smbData.DirectoryName.Length);

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

            return packet;
        }
        public SmbDeleteDirectoryResponsePacket CreateDeleteDirectoryResponse(
            CifsServerPerConnection connection,
            SmbDeleteDirectoryRequestPacket request)
        {
            SmbDeleteDirectoryResponsePacket response = new SmbDeleteDirectoryResponsePacket();
            response.SmbHeader = CifsMessageUtils.CreateSmbHeader(connection, request);

            return response;
        }