void IDestinationMailbox.CreateFolder(FolderRec sourceFolder, CreateFolderFlags createFolderFlags, out byte[] newFolderId) { MrsTracer.Provider.Function("PstDestinationMailbox.CreateFolder(\"{0}\")", new object[] { sourceFolder.FolderName }); newFolderId = null; uint nodeIdFromEntryId = PstMailbox.GetNodeIdFromEntryId(base.IPst.MessageStore.Guid, sourceFolder.ParentId); if (sourceFolder.EntryId != null) { uint nodeIdFromEntryId2 = PstMailbox.GetNodeIdFromEntryId(base.IPst.MessageStore.Guid, sourceFolder.EntryId); IFolder folder = base.IPst.ReadFolder(nodeIdFromEntryId2); if (folder != null) { if (createFolderFlags.HasFlag(CreateFolderFlags.FailIfExists)) { throw new UnableToReadPSTFolderPermanentException(nodeIdFromEntryId2); } if (nodeIdFromEntryId == folder.ParentId) { return; } } } IFolder folder2 = base.IPst.ReadFolder(nodeIdFromEntryId); if (folder2 == null) { throw new UnableToReadPSTFolderPermanentException(nodeIdFromEntryId); } using (PstFxFolder pstFxFolder = new PstFxFolder(this, folder2.AddFolder())) { pstFxFolder.PropertyBag.SetProperty(new PropertyValue(PropertyTag.DisplayName, sourceFolder.FolderName)); pstFxFolder.PropertyBag.SetProperty(new PropertyValue(PropertyTag.FolderType, (int)sourceFolder.FolderType)); newFolderId = PstMailbox.CreateEntryIdFromNodeId(base.IPst.MessageStore.Guid, pstFxFolder.IPstFolder.Id); } }
private void MoveProjectItems(ProjectItems sourceProjectItems, IFolder targetFolder, string sourceName, string targetName) { // Keep a list of items that have been moved so that we don't modify the sourceProjectItems enumerable. var itemsToDeleteFromSource = new List<ProjectItem>(); foreach (ProjectItem item in sourceProjectItems) { string itemName = item.Name; if (item.IsOpen && item.IsDirty) { item.Save(); } if (CanBeMigrated(item)) { OutputWindow.WriteLine("Copying item " + itemName + " from project " + sourceName + " into project " + targetName + "..."); for (short i = 0; i < item.FileCount; i++) { if (item.IsPhysicalDirectory()) { var directoryName = item.Name; OutputWindow.WriteLine("Copying directory " + directoryName + " from project " + sourceName + " into project " + targetName + "..."); var newDirectory = targetFolder.AddFolder(directoryName); MoveProjectItems(item.ProjectItems, newDirectory, sourceName + "/" + directoryName, targetName + "/" + directoryName); OutputWindow.WriteLine("Copied directory " + directoryName + " from project " + sourceName + " into project " + targetName + "."); } else if (item.IsPhysicalFile()) { var fileName = item.FileNames[i]; OutputWindow.WriteLine("Copying file " + fileName + " from project " + sourceName + " into project " + targetName + "..."); targetFolder.AddFromFileCopy(fileName); OutputWindow.WriteLine("Copied file " + fileName + " from project " + sourceName + " into project " + targetName + "."); } else { OutputWindow.WriteLine("Unsupported item Kind " + item.Kind + ". This item won't be moved to the project " + targetName + "."); } } itemsToDeleteFromSource.Add(item); OutputWindow.WriteLine("Copied item " + itemName + " from project " + sourceName + " into project " + targetName); } else { OutputWindow.WriteLine("Ignoring special item '" + item.Name + "'. This item cannot be migrated."); } } foreach (var item in itemsToDeleteFromSource) { var itemName = item.Name; OutputWindow.WriteLine("Deleting item '" + itemName + "' from source project..."); item.Delete(); OutputWindow.WriteLine("Deleted item '" + itemName + "' from source project."); } }