public static void MoveSharedItems(object parentId, object toId, IFolderDao folderDao, IFileDao fileDao) { var fileSecurity = Global.GetFilesSecurity(); var folders = folderDao.GetFolders(parentId); foreach (var folder in folders) { var shared = folder.Shared && fileSecurity.GetShares(folder).Any(record => record.Share != FileShare.Restrict); if (shared) { Global.Logger.InfoFormat("Move shared folder {0} from {1} to {2}", folder.ID, parentId, toId); folderDao.MoveFolder(folder.ID, toId, null); } else { MoveSharedItems(folder.ID, toId, folderDao, fileDao); } } var files = fileDao.GetFiles(parentId, null, FilterType.None, false, Guid.Empty, string.Empty, true); foreach (var file in files.Where(file => file.Shared && fileSecurity.GetShares(file) .Any(record => record.Subject != FileConstant.ShareLinkId && record.Share != FileShare.Restrict))) { Global.Logger.InfoFormat("Move shared file {0} from {1} to {2}", file.ID, parentId, toId); fileDao.MoveFile(file.ID, toId); } }