コード例 #1
0
        /// <summary>
        /// Deletes the folder.
        /// </summary>
        /// <param name="folder">The folder.</param>
        public static void DeleteFolder(CalendarFolder folder)
        {
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                TreeService treeService = folder.GetTreeService();

                //Erase all child folders
                foreach (TreeNode node in TreeManager.GetAllChildNodes(treeService.CurrentNode))
                {
                    CalendarFolder childFolder = (CalendarFolder)node.InnerObject;
                    EraseFolder(childFolder);
                    treeService.RemoveChild(node.ObjectId);
                    childFolder.Delete();
                }

                //Erase current folder
                EraseFolder(folder);
                folder.Delete();

                tran.Commit();
            }
        }