// this should only run once on startup private void SetDefaultBuildDirectory() { // load up the builds from Builds.xml using (XmlReader reader = XmlReader.Create($@"Xml\{XmlBaseFolder}\Builds.xml")) { reader.MoveToContent(); if (reader.Name != "Builds") { return; } while (reader.Read()) { if (reader.IsStartElement()) { string type = reader["type"]; string link = reader["link"]; string pre = reader["pre"]; try { if (reader.Read()) { if (string.IsNullOrEmpty(pre)) { BuildPatchNotesByBuildNumber.Add(Convert.ToInt32(reader.Value), new Tuple <string, string>(type, link)); } else { var previousBuild = BuildPatchNotesByBuildNumber[Convert.ToInt32(pre)]; BuildPatchNotesByBuildNumber.Add(Convert.ToInt32(reader.Value), new Tuple <string, string>(previousBuild.Item1, previousBuild.Item2)); } } } catch (FormatException ex) { throw new ParseXmlException($"Could not convert to Int32: {pre} | {reader.Value}", ex); } } } } foreach (var build in BuildPatchNotesByBuildNumber) { int buildNumber = build.Key; if (!Directory.Exists($@"Xml\{XmlBaseFolder}\{buildNumber}")) { throw new ParseXmlException($"Could not find required Build Folder: Xml\\{XmlBaseFolder}\\{buildNumber}"); } else { Builds.Add(buildNumber); } } Builds = Builds.OrderByDescending(x => x).ToList(); EarliestHeroesBuild = Builds[Builds.Count - 1]; LatestHeroesBuild = SelectedBuild = Builds[0]; }