public void volcar() { try { hayRuta(); hayRutaVolcado(); sr = new StreamReader(rutaVolcado); fs = new FileStream(ruta, FileMode.Append); string linea = sr.ReadLine(); while (linea != null) { string[] datos = linea.Split(','); string titulo = datos[0].Trim(); string genero = datos[1].Trim(); int precio = Convert.ToInt32(datos[2].Trim()); DateTime dt = DateTime.Parse(datos[3]); int estado = Convert.ToInt32(datos[4]); Juego jj = new Juego(precio, titulo, genero, dt, estado); fs.Write(Encoding.ASCII.GetBytes(jj.arreglar()), 0, Juego.TAMREGISTRO); linea = sr.ReadLine(); } sr.Close(); fs.Close(); } catch (Exception ee) { sr.Close(); fs.Close(); throw ee; } }
public void escribirAlFinal(Juego juego) { try { hayRuta(); string escribir = juego.arreglar(); fs = new FileStream(ruta, FileMode.Append); fs.Write(Encoding.ASCII.GetBytes(escribir), 0, Juego.TAMREGISTRO); fs.Close(); } catch (Exception ee) { fs.Close(); throw ee; } }