private void btnRegistrar_Click(object sender, EventArgs e) { Clima climaTemp = new Clima(); climaTemp.Codigo = cmbDepartamento.SelectedValue.ToString(); climaTemp.Temperatura = float.Parse(txtTemperatura.Text); climaTemp.FechaMedicion = mcFecha.SelectionStart; climas.Add(climaTemp); GuardarTemperatura(); Limpiar(); }
private void LeerTemperatura() { if (File.Exists("Temperaturas.txt")) { FileStream stream = new FileStream("Temperaturas.txt", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(stream); while (reader.Peek() > -1) { Clima climaTemp = new Clima(); climaTemp.Codigo = reader.ReadLine(); climaTemp.Temperatura = float.Parse(reader.ReadLine()); climaTemp.FechaMedicion = Convert.ToDateTime(reader.ReadLine()); climas.Add(climaTemp); } reader.Close(); } }