Inheritance: FolderChangeDescriptionType
        /// <summary>
        /// Generate the request message for operation "UpdateFolder".
        /// </summary>
        /// <param name="folderType">An array of folder types.</param>
        /// <param name="updateType">An array of update folder types.</param>
        /// <param name="folderIds">An array of folder Ids.</param>
        /// <returns>Update folder request instance that will send to server.</returns>
        protected UpdateFolderType GetUpdateFolderRequest(string[] folderType, string[] updateType, FolderIdType[] folderIds)
        {
            Site.Assert.AreEqual<int>(folderType.Length, folderIds.Length, "Folder type count should equal to folder id count!");
            Site.Assert.AreEqual<int>(folderType.Length, updateType.Length, "Folder type count should equal to update type count!");

            // UpdateFolder request.
            UpdateFolderType updateFolderRequest = new UpdateFolderType();
            int folderCount = folderIds.Length;

            // Set the request's folder id field to Custom Folder's folder id.
            updateFolderRequest.FolderChanges = new FolderChangeType[folderCount];
            for (int folderIndex = 0; folderIndex < folderCount; folderIndex++)
            {
                updateFolderRequest.FolderChanges[folderIndex] = new FolderChangeType();
                updateFolderRequest.FolderChanges[folderIndex].Item = folderIds[folderIndex];

                // Add the array of changes; in this case, a single element array.
                updateFolderRequest.FolderChanges[folderIndex].Updates = new FolderChangeDescriptionType[1];

                switch (updateType[folderIndex])
                {
                    case "SetFolderField":
                        {
                            // Set the new folder name of the specific folder.
                            SetFolderFieldType setFolderField = new SetFolderFieldType();
                            PathToUnindexedFieldType displayNameProp = new PathToUnindexedFieldType();
                            displayNameProp.FieldURI = UnindexedFieldURIType.folderDisplayName;

                            switch (folderType[folderIndex])
                            {
                                case "Folder":
                                    FolderType updatedFolder = new FolderType();
                                    updatedFolder.DisplayName = Common.GenerateResourceName(this.Site, "UpdatedFolder" + folderIndex);
                                    setFolderField.Item1 = updatedFolder;
                                    break;
                                case "CalendarFolder":
                                    CalendarFolderType updatedCalendarFolder = new CalendarFolderType();
                                    updatedCalendarFolder.DisplayName = Common.GenerateResourceName(this.Site, "UpdatedFolder" + folderIndex);
                                    setFolderField.Item1 = updatedCalendarFolder;
                                    break;
                                case "ContactsFolder":
                                    CalendarFolderType updatedContactFolder = new CalendarFolderType();
                                    updatedContactFolder.DisplayName = Common.GenerateResourceName(this.Site, "UpdatedFolder" + folderIndex);
                                    setFolderField.Item1 = updatedContactFolder;
                                    break;
                                case "SearchFolder":
                                    CalendarFolderType updatedSearchFolder = new CalendarFolderType();
                                    updatedSearchFolder.DisplayName = Common.GenerateResourceName(this.Site, "UpdatedFolder" + folderIndex);
                                    setFolderField.Item1 = updatedSearchFolder;
                                    break;
                                case "TasksFolder":
                                    CalendarFolderType updatedTaskFolder = new CalendarFolderType();
                                    updatedTaskFolder.DisplayName = Common.GenerateResourceName(this.Site, "UpdatedFolder" + folderIndex);
                                    setFolderField.Item1 = updatedTaskFolder;
                                    break;

                                default:
                                    FolderType generalFolder = new FolderType();
                                    generalFolder.DisplayName = Common.GenerateResourceName(this.Site, "UpdatedFolder" + folderIndex);
                                    setFolderField.Item1 = generalFolder;
                                    break;
                            }

                            setFolderField.Item = displayNameProp;
                            updateFolderRequest.FolderChanges[folderIndex].Updates[0] = setFolderField;
                        }

                        break;
                    case "DeleteFolderField":
                        {
                            // Use DeleteFolderFieldType.
                            DeleteFolderFieldType delFolder = new DeleteFolderFieldType();
                            PathToUnindexedFieldType delProp = new PathToUnindexedFieldType();
                            delProp.FieldURI = UnindexedFieldURIType.folderPermissionSet;
                            delFolder.Item = delProp;
                            updateFolderRequest.FolderChanges[folderIndex].Updates[0] = delFolder;
                        }

                        break;
                    case "AppendToFolderField":
                        {
                            // Use AppendToFolderFieldType.
                            AppendToFolderFieldType appendToFolderField = new AppendToFolderFieldType();
                            PathToUnindexedFieldType displayNameAppendTo = new PathToUnindexedFieldType();
                            displayNameAppendTo.FieldURI = UnindexedFieldURIType.calendarAdjacentMeetings;
                            appendToFolderField.Item = displayNameAppendTo;
                            FolderType folderAppendTo = new FolderType();
                            folderAppendTo.FolderId = folderIds[folderIndex];
                            appendToFolderField.Item1 = folderAppendTo;
                            updateFolderRequest.FolderChanges[folderIndex].Updates[0] = appendToFolderField;
                        }

                        break;
                }
            }

            return updateFolderRequest;
        }
        /// <summary>
        /// Log on to a mailbox with a specified user account and find the specified folder then update the folder name of it.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">Password of the user.</param>
        /// <param name="userDomain">Domain of the user.</param>
        /// <param name="parentFolderName">Name of the parent folder.</param>
        /// <param name="currentFolderName">Current name of the folder which will be updated.</param>
        /// <param name="newFolderName">New name of the folder which will be updated to.</param>
        /// <returns>If the name of the folder is updated successfully, return true; otherwise, return false.</returns>
        public bool FindAndUpdateFolderName(string userName, string userPassword, string userDomain, string parentFolderName, string currentFolderName, string newFolderName)
        {
            // Switch to specified user mailbox.
            bool isSwitched = AdapterHelper.SwitchUser(userName, userPassword, userDomain, this.exchangeServiceBinding, this.Site);
            Site.Assert.IsTrue(
                isSwitched,
                string.Format("Log on mailbox with the UserName: {0}, Password: {1}, Domain: {2} should be successful.", userName, userPassword, userDomain));

            // Parse the parent folder name to DistinguishedFolderIdNameType.
            DistinguishedFolderIdNameType parentFolderIdName = (DistinguishedFolderIdNameType)Enum.Parse(typeof(DistinguishedFolderIdNameType), parentFolderName, true);

            // Create UpdateFolder request
            UpdateFolderType updateFolderRequest = new UpdateFolderType();
            updateFolderRequest.FolderChanges = new FolderChangeType[1];
            updateFolderRequest.FolderChanges[0] = new FolderChangeType();
            updateFolderRequest.FolderChanges[0].Item = this.FindSubFolder(parentFolderIdName, currentFolderName);

            // Identify the field to update and the value to set for it.
            SetFolderFieldType displayName = new SetFolderFieldType();
            PathToUnindexedFieldType displayNameProp = new PathToUnindexedFieldType();
            displayNameProp.FieldURI = UnindexedFieldURIType.folderDisplayName;
            FolderType updatedFolder = new FolderType();
            updatedFolder.DisplayName = newFolderName;
            displayName.Item = displayNameProp;
            updatedFolder.DisplayName = newFolderName;
            displayName.Item1 = updatedFolder;

            // Add a single element into the array of changes.
            updateFolderRequest.FolderChanges[0].Updates = new FolderChangeDescriptionType[1];
            updateFolderRequest.FolderChanges[0].Updates[0] = displayName;
            bool isFolderNameUpdated = false;

            // Invoke the UpdateFolder operation and get the response.
            UpdateFolderResponseType updateFolderResponse = this.exchangeServiceBinding.UpdateFolder(updateFolderRequest);

            if (updateFolderResponse != null && ResponseClassType.Success == updateFolderResponse.ResponseMessages.Items[0].ResponseClass)
            {
                isFolderNameUpdated = true;
            }

            return isFolderNameUpdated;
        }