private static DiskItem[] GetItems(string rootPath) { Assert.ArgumentNotNullOrEmpty(rootPath, "path"); if (!Directory.Exists(rootPath)) { return(new DiskItem[0]); } var files = Directory.GetFiles(rootPath, string.Format("*{0}", PathUtils.Extension), SearchOption.AllDirectories); var diskItems = new List <DiskItem>(files.Length); foreach (var subPath in files) { try { var item = new DiskItem(subPath); diskItems.Add(item); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine("Error: unable to read serialized format: {0}", subPath); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } } return(diskItems.ToArray()); }
private static DiskItem[] GetItems(string rootPath) { Assert.ArgumentNotNullOrEmpty(rootPath, "path"); if (!Directory.Exists(rootPath)) { return new DiskItem[0]; } var files = Directory.GetFiles(rootPath, string.Format("*{0}", PathUtils.Extension), SearchOption.AllDirectories); var diskItems = new List<DiskItem>(files.Length); foreach(var subPath in files) { try { var item = new DiskItem(subPath); diskItems.Add(item); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(); Console.WriteLine("Error: unable to read serialized format: {0}", subPath); Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.ResetColor(); } } return diskItems.ToArray(); }