} //изменяю статус автобуса (свободен/ занят) public List <Passanger> ReadFromCSVPassanger() { bool done = false; List <Passanger> allPassangers = new List <Passanger>(); while (done == false) { try { var reader = new StreamReader(filepathpassengers); int counter = 0; while (reader.ReadLine() != null) { counter++; } reader.Close(); reader = new StreamReader(filepathpassengers); int k = 0; while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(';'); var temp = new Passanger(); temp.passangerId = Convert.ToInt32(values[0]); temp.busId = Convert.ToInt32(values[1]); allPassangers.Add(temp); k++; } reader.Close(); done = true; } catch (Exception e) { } } return(allPassangers); } //прочитать всех пассажиров
} //вписать автобус public void WriteToCSVPassanger(Passanger pas) { bool done = false; while (done == false) { try { StringBuilder sb = new StringBuilder(); sb.AppendLine(pas.passangerId + delimiter + pas.busId + delimiter); File.AppendAllText(filepathpassengers, sb.ToString()); done = true; } catch (Exception e) { } } } //вписать пассажира