コード例 #1
0
        public PSTFolder FindChildFolder(string displayNameToFind)
        {
            TableContext tc = GetHierarchyTable();

            if (tc != null)
            {
                for (int index = 0; index < tc.RowCount; index++)
                {
                    string displayName = tc.GetStringProperty(index, PropertyID.PidTagDisplayName);
                    if (displayName == displayNameToFind)
                    {
                        NodeID childNodeID = new NodeID(tc.GetRowID(index));
                        return(PSTFolder.GetFolder(File, childNodeID));
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Caller must update its hierarchy table to include the new child
        /// </summary>
        public static PSTFolder CreateNewFolder(PSTFile file, string folderName, FolderItemTypeName folderItemType, NodeID parentNodeID)
        {
            // create the normal folder node
            PropertyContext pc = PropertyContext.CreateNewPropertyContext(file);

            pc.SetStringProperty(PropertyID.PidTagDisplayName, folderName);
            pc.SetInt32Property(PropertyID.PidTagContentCount, 0);
            pc.SetInt32Property(PropertyID.PidTagContentUnreadCount, 0);
            pc.SetBooleanProperty(PropertyID.PidTagSubfolders, false);
            pc.SetStringProperty(PropertyID.PidTagContainerClass, GetContainerClass(folderItemType));
            pc.SaveChanges();

            NodeID pcNodeID = file.Header.AllocateNextFolderNodeID();

            file.NodeBTree.InsertNodeEntry(pcNodeID, pc.DataTree, pc.SubnodeBTree, parentNodeID);
            PSTNode pcNode = new PSTNode(file, pcNodeID, pc.DataTree, pc.SubnodeBTree);

            // There is no need to create a new empty TC, we can simply point to the appropriate template
            // and only update the reference to another data tree during modification
            PSTNode hierarchyTableTemplateNode = file.GetNode(InternalNodeName.NID_HIERARCHY_TABLE_TEMPLATE);
            NodeID  hierarchyTableNodeID       = new NodeID(NodeTypeName.NID_TYPE_HIERARCHY_TABLE, pcNodeID.nidIndex);

            file.NodeBTree.InsertNodeEntry(hierarchyTableNodeID, hierarchyTableTemplateNode.DataTree, null, new NodeID(0));
            file.BlockBTree.IncrementBlockEntryReferenceCount(hierarchyTableTemplateNode.DataTree.RootBlock.BlockID);

            PSTNode contentsTableTemplateNode = file.GetNode(InternalNodeName.NID_CONTENTS_TABLE_TEMPLATE);
            NodeID  contentsTableNodeID       = new NodeID(NodeTypeName.NID_TYPE_CONTENTS_TABLE, pcNodeID.nidIndex);

            file.NodeBTree.InsertNodeEntry(contentsTableNodeID, contentsTableTemplateNode.DataTree, null, new NodeID(0));
            file.BlockBTree.IncrementBlockEntryReferenceCount(contentsTableTemplateNode.DataTree.RootBlock.BlockID);

            PSTNode associatedContentsTableTemplateNode = file.GetNode(InternalNodeName.NID_ASSOC_CONTENTS_TABLE_TEMPLATE);
            NodeID  associatedContentsTableNodeID       = new NodeID(NodeTypeName.NID_TYPE_ASSOC_CONTENTS_TABLE, pcNodeID.nidIndex);

            file.NodeBTree.InsertNodeEntry(associatedContentsTableNodeID, associatedContentsTableTemplateNode.DataTree, null, new NodeID(0));
            file.BlockBTree.IncrementBlockEntryReferenceCount(associatedContentsTableTemplateNode.DataTree.RootBlock.BlockID);

            PSTFolder folder = PSTFolder.GetFolder(pcNode);

            return(folder);
        }
コード例 #3
0
        public List <PSTFolder> GetChildFolders()
        {
            TableContext tc = GetHierarchyTable();

            List <PSTFolder> result = new List <PSTFolder>();

            if (tc != null)
            {
                for (int index = 0; index < tc.RowCount; index++)
                {
                    // dwRowID is the NodeID
                    NodeID childNodeID = new NodeID(tc.GetRowID(index));
                    if (childNodeID.nidType == NodeTypeName.NID_TYPE_NORMAL_FOLDER)
                    {
                        PSTFolder childFolder = PSTFolder.GetFolder(File, childNodeID);
                        result.Add(childFolder);
                    }
                }
            }
            return(result);
        }
コード例 #4
0
        public PSTFolder GetFolder(NodeID nodeID)
        {
            PSTFolder folder = PSTFolder.GetFolder(this, nodeID);

            return(folder);
        }