private static void DiscoverBackups(DirectoryItem dirItem) { try { var hlinks = new List <string>(); var bckps = BackupInfo.DiscoverBackups(dirItem.Path).ToList(); if (bckps.Count > 0) { dirItem.HasBackups = true; foreach (var bkp in bckps) { var bkpDirItem = dirItem.Items.OfType <DirectoryItem>().First(i => i.Path == bkp.AbsolutePath); bkpDirItem.IsBackup = true; object processedFiles; var files = bkp.Files; /*foreach (var file in files) * { * var fPath = bkp.AbsolutePath + file.Path; * var links = HardLinkHelper.GetHardLinksRooted(fPath); * hlinks.AddRange(links.Where(lnk => !string.Equals(lnk, fPath, StringComparison.OrdinalIgnoreCase))); * * }*/ } } else { foreach (var i in dirItem.Items.OfType <DirectoryItem>()) { DiscoverBackups(i); } } } catch (Exception e) { Console.WriteLine(e); } }
public List <Item> GetItems(string path) { var items = new List <Item>(); var dirInfo = new DirectoryInfo(path); try { foreach (var directory in dirInfo.GetDirectories()) { var item = new DirectoryItem { Name = directory.Name, Path = directory.FullName, Items = GetItems(directory.FullName) }; items.Add(item); } foreach (var file in dirInfo.GetFiles()) { var item = new FileItem { Name = file.Name, Path = file.FullName }; items.Add(item); } } catch (Exception e) { Console.WriteLine(e); } return(items); }