public void UpdateFolderContent() { var existedPaths = new List<string>(); if (Directory.Exists(OriginalPath)) { foreach (var folder in Directory.GetDirectories(OriginalPath).Select(folderPath => new DirectoryInfo(folderPath))) { existedPaths.Add(folder.FullName); if (FolderContent.Any(x => x.OriginalPath.ToLower().Equals(folder.FullName.ToLower()))) continue; var libraryFile = new LibraryFolderLink(Parent); libraryFile.Name = folder.Name; libraryFile.RootId = RootId; var rootFolder = Parent.Parent.Parent.GetRootFolder(RootId); libraryFile.RelativePath = (rootFolder.IsDrive ? @"\" : string.Empty) + folder.FullName.Replace(rootFolder.Folder.FullName, string.Empty); libraryFile.Type = FileTypes.Folder; libraryFile.UpdateFolderContent(); libraryFile.InitBannerProperties(); FolderContent.Add(libraryFile); } foreach (var file in Directory.GetFiles(OriginalPath).Where(x => !x.ToLower().Contains("thumbs.db")).Select(filePath => new FileInfo(filePath))) { existedPaths.Add(file.FullName); if (FolderContent.Any(x => x.OriginalPath.ToLower().Equals(file.FullName.ToLower()))) continue; var libraryFile = new LibraryLink(Parent); libraryFile.Name = file.Name; libraryFile.RootId = RootId; var rootFolder = Parent.Parent.Parent.GetRootFolder(RootId); libraryFile.RelativePath = (rootFolder.IsDrive ? @"\" : string.Empty) + file.FullName.Replace(rootFolder.Folder.FullName, string.Empty); libraryFile.SetProperties(); libraryFile.InitBannerProperties(); FolderContent.Add(libraryFile); } } FolderContent.RemoveAll(x => !existedPaths.Any(y => y.ToLower().Equals(x.OriginalPath.ToLower()))); for (int i = 0; i < FolderContent.Count; i++) FolderContent[i].Order = i; }