/// <summary> /// Moves the folder and files at the specified folder path to the new folder path. /// </summary> public virtual void MoveFolder(string folderPath, string newFolderPath, FolderMappingInfo folderMapping) { Requires.NotNullOrEmpty("folderPath", folderPath); Requires.NotNullOrEmpty("newFolderPath", newFolderPath); Requires.NotNull("folderMapping", folderMapping); var folderProvider = Instance(folderMapping.FolderProviderType); AddFolderAndMoveFiles(folderPath, newFolderPath, folderMapping); var folderManager = new FolderManager(); var subFolders = folderManager.GetFolderMappingFoldersRecursive(folderMapping, folderPath).Skip(1).Reverse(); foreach (var subFolderPath in subFolders.Select(s => s.Key)) { var newSubFolderPath = newFolderPath + subFolderPath.Substring(folderPath.Length); AddFolderAndMoveFiles(subFolderPath, newSubFolderPath, folderMapping); folderProvider.DeleteFolder(new FolderInfo { FolderPath = subFolderPath, FolderMappingID = folderMapping.FolderMappingID, PortalID = folderMapping.FolderMappingID }); } folderProvider.DeleteFolder(new FolderInfo { FolderPath = folderPath, FolderMappingID = folderMapping.FolderMappingID, PortalID = folderMapping.PortalID }); }
/// <summary> /// Moves the folder and files at the specified folder path to the new folder path. /// </summary> public virtual void MoveFolder(string folderPath, string newFolderPath, FolderMappingInfo folderMapping) { Requires.NotNullOrEmpty("folderPath", folderPath); Requires.NotNullOrEmpty("newFolderPath", newFolderPath); Requires.NotNull("folderMapping", folderMapping); var folderProvider = Instance(folderMapping.FolderProviderType); AddFolderAndMoveFiles(folderPath, newFolderPath, folderMapping); var folder = FolderManager.Instance.GetFolder(folderMapping.PortalID, folderPath); var folderManager = new FolderManager(); var subFolders = folderManager.GetFolderMappingFoldersRecursive(folderMapping, folder).Skip(1).Reverse(); foreach (var subFolderPath in subFolders.Select(s => s.Key)) { var newSubFolderPath = newFolderPath + subFolderPath.Substring(folderPath.Length); AddFolderAndMoveFiles(subFolderPath, newSubFolderPath, folderMapping); folderProvider.DeleteFolder(new FolderInfo { FolderPath = subFolderPath, FolderMappingID = folderMapping.FolderMappingID, PortalID = folderMapping.FolderMappingID }); } folderProvider.DeleteFolder(new FolderInfo { FolderPath = folderPath, FolderMappingID = folderMapping.FolderMappingID, PortalID = folderMapping.PortalID }); }