public static void Serializa(ListaTareas lista)
		{
			XmlSerializer xser = new XmlSerializer(lista.GetType());
			StreamWriter sw = File.CreateText(FILE);
			xser.Serialize(sw, lista);
			sw.Close();
		}
Beispiel #2
0
        public static void Guardar(ListaTareas lista)
        {
            StreamWriter sw = new StreamWriter(FILE, false);

            foreach (Tarea t in lista)
            {
                sw.WriteLine(t.ToString2());
            }

            sw.Close();
        }
        public MainWindow()
        {
            InitializeComponent();

            tareas = (ListaTareas)XMLSerializa.Deserializa(); //Archivo.Abrir();

            if (tareas == null)
            {
                tareas = new ListaTareas();
            }

            ActualizarDataGrid();
        }
		public static object Deserializa()
		{
			ListaTareas lista = new ListaTareas();
			XmlSerializer xser = new XmlSerializer(lista.GetType());
			
			FileStream fs = new FileStream(FILE, FileMode.OpenOrCreate);
			StreamReader sr = new StreamReader(fs);
			
			try {
				lista = (ListaTareas) xser.Deserialize(sr);
			} catch (Exception) {
				lista = null;
			} finally {
				sr.Close();
				fs.Close();
			}

			return lista;
		}
Beispiel #5
0
        public static ListaTareas Abrir()
        {
            ListaTareas lista = new ListaTareas();
            string linea;
            StreamReader sr = null;

            try
            {
                sr = new StreamReader(FILE);

                while ((linea = sr.ReadLine()) != null)
                {
                    lista.Add(new Tarea(linea));
                }

                sr.Close();
            }
            catch (FileNotFoundException)
            {
                File.CreateText(FILE);
            }

            return lista;
        }
 public MainWindow()
 {
     InitializeComponent();
     tareas = new ListaTareas();    
 }