/// <summary> /// Read all waypoints from ats.txt file. /// Returns the error message if failed to parse some lines, or null. /// </summary> /// <param name="filepath">Path of ats.txt</param> /// <exception cref="WaypointFileReadException"></exception> public static string ReadFromFile(WaypointList wptList, string filepath) { try { var allLines = File.ReadLines(filepath); var errors = Read(wptList, allLines); return(ReadFileErrorMsg.ErrorMsg(errors, "ats.txt")); } catch (Exception e) { throw new WaypointFileReadException("Failed to read ats.txt.", e); } }
/// <exception cref="Exception"></exception> private void InitAirportAndWaypoints() { string navDataPath = AppSettings.NavDataLocation; var airportTxtPath = Path.Combine(navDataPath, "Airports.txt"); var airportResult = AirportDataLoader.LoadFromFile(airportTxtPath); var err = airportResult.Errors; if (err.Any()) { Log(ReadFileErrorMsg.ErrorMsg(err, "ats.txt")); } var airports = airportResult.Airports; var result = new WptListLoader(navDataPath).LoadFromFile(); countryCodesLocator = result.CountryCodes.ToLocator(); airwayNetwork = new AirwayNetwork(result.WptList, airports); }
// If failed, returns null. private AirportManager TryLoadAirports() { try { var directory = pathTxtBox.Text; var filePath = Path.Combine(directory, "Airports.txt"); var loadResult = AirportDataLoader.LoadFromFile(filePath); var err = loadResult.Errors; if (err.Any()) { Log(ReadFileErrorMsg.ErrorMsg(err, "ats.txt")); } return(loadResult.Airports); } catch (Exception ex) { Log(ex); this.ShowError("Failed to load airports.txt."); return(null); } }