public override string MoveDirectory(string path, string newPath) { try { var virtualPath = FileSystemValidation.ToVirtualPath(path); var virtualNewPath = FileSystemValidation.ToVirtualPath(newPath); var virtualDestinationPath = FileSystemValidation.GetDestinationFolder(virtualNewPath); string returnValue; var isRename = FileSystemValidation.GetDestinationFolder(virtualPath) == virtualDestinationPath; if (isRename) { //rename directory returnValue = DNNValidator.OnRenameFolder(virtualPath); if (!(string.IsNullOrEmpty(returnValue))) { return(returnValue); } } else { //move directory returnValue = DNNValidator.OnMoveFolder(virtualPath, virtualDestinationPath); if (!(string.IsNullOrEmpty(returnValue))) { return(returnValue); } } //Are all items visible to user? FolderInfo folder = DNNValidator.GetUserFolder(virtualPath); if (!(CheckAllChildrenVisible(ref folder))) { return(DNNValidator.LogDetailError(ErrorCodes.CannotMoveFolder_ChildrenVisible)); } if (isRename) { var dnnFolderToRename = FolderManager.Instance.GetFolder(PortalSettings.PortalId, FileSystemValidation.ToDBPath(virtualPath)); var newFolderName = virtualNewPath.TrimEnd('/').Split('/').LastOrDefault(); FolderManager.Instance.RenameFolder(dnnFolderToRename, newFolderName); } else // move { var dnnFolderToMove = FolderManager.Instance.GetFolder(PortalSettings.PortalId, FileSystemValidation.ToDBPath(virtualPath)); var dnnDestinationFolder = FolderManager.Instance.GetFolder(PortalSettings.PortalId, FileSystemValidation.ToDBPath(virtualDestinationPath)); FolderManager.Instance.MoveFolder(dnnFolderToMove, dnnDestinationFolder); } return(returnValue); } catch (Exception ex) { return(DNNValidator.LogUnknownError(ex, path, newPath)); } }
public override string MoveDirectory(string path, string newPath) { try { string virtualPath = (string)(string)FileSystemValidation.ToVirtualPath(path); string virtualNewPath = (string)(string)FileSystemValidation.ToVirtualPath(newPath); string virtualDestinationPath = FileSystemValidation.GetDestinationFolder(virtualNewPath); string returnValue = string.Empty; if (FileSystemValidation.GetDestinationFolder(virtualPath) == virtualDestinationPath) { //rename directory returnValue = DNNValidator.OnRenameFolder(virtualPath); if (!(string.IsNullOrEmpty(returnValue))) { return(returnValue); } } else { //move directory returnValue = DNNValidator.OnMoveFolder(virtualPath, virtualDestinationPath); if (!(string.IsNullOrEmpty(returnValue))) { return(returnValue); } } //Are all items visible to user? FolderInfo folder = DNNValidator.GetUserFolder(virtualPath); if (!(CheckAllChildrenVisible(ref folder))) { return(DNNValidator.LogDetailError(ErrorCodes.CannotMoveFolder_ChildrenVisible)); } //Returns errors or empty string when successful (ie: Cannot create a file when that file already exists) returnValue = TelerikContent.MoveDirectory(virtualPath, virtualNewPath); if (string.IsNullOrEmpty(returnValue)) { //make sure folder name is being updated in database DNNValidator.OnFolderRenamed(virtualPath, virtualNewPath); //Sync to remove old folder & files FileSystemUtils.SynchronizeFolder(PortalSettings.PortalId, HttpContext.Current.Request.MapPath(virtualPath), FileSystemValidation.ToDBPath(virtualPath), true, true, true); //Sync to add new folder & files FileSystemUtils.SynchronizeFolder(PortalSettings.PortalId, HttpContext.Current.Request.MapPath(virtualNewPath), FileSystemValidation.ToDBPath(virtualNewPath), true, true, true); } return(returnValue); } catch (Exception ex) { return(DNNValidator.LogUnknownError(ex, path, newPath)); } }