/// <summary> /// Checks if the previous folders of an offline folder node path are empty /// and removes them from the offline folder and the DB on this case. /// </summary> /// <param name="folderNodePath">Path of the folder node</param> /// <returns>TRUE if the process finished successfully or FALSE in other case.</returns> public static bool CleanOfflineFolderNodePath(string folderNodePath) { if (string.IsNullOrWhiteSpace(folderNodePath)) { return(false); } var result = true; while (string.CompareOrdinal(folderNodePath, AppService.GetOfflineDirectoryPath()) != 0) { try { if (!FolderService.FolderExists(folderNodePath)) { return(false); } var folderPathToRemove = folderNodePath; if (!FolderService.IsEmptyFolder(folderPathToRemove)) { return(true); } var directoryInfo = new DirectoryInfo(folderNodePath).Parent; if (directoryInfo == null) { return(true); } folderNodePath = directoryInfo.FullName; result &= FolderService.DeleteFolder(folderPathToRemove); result &= SavedForOfflineDB.DeleteNodeByLocalPath(folderPathToRemove); } catch (Exception e) { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, string.Format("Error cleaning offline node path '{0}'", folderNodePath), e); return(false); } } return(result); }