public static List <Docente> LeerArchivoDocente()
        {
            ArchivoXml <List <Docente> > archivo = new ArchivoXml <List <Docente> >();
            List <Docente> nueva = null;

            string ruta = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\SegundoParcialUtn\JardinUtn\Docentes\Docentes.xml";

            try
            {
                if (archivo.LeerArchivo(ruta, out nueva))
                {
                }
                else
                {
                    throw new Exception("Error al Leer");
                }
            }
            catch (Exception ex)
            {
                Log.GuardarErrorExcepcion(ex);
            }
            finally
            {
            }
            return(nueva);
        }
示例#2
0
      public static bool Guardar(Alumno alumno, bool aprobado)
      {
          bool seGuardo = false;

          try
          {
              IArchivo <Alumno> archivo = new ArchivoXml <Alumno>();

              if (aprobado)
              {
                  string ruta = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\SegundoParcialUtn\JardinUtn\Aprobados";

                  if (!Directory.Exists(ruta))
                  {
                      Directory.CreateDirectory(ruta);
                      throw new ArchivoException("Se creo directorio Aprobados por que no existe");
                  }
                  if (archivo.GuardarArchivo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\SegundoParcialUtn\JardinUtn\Aprobados\" + alumno.Nombre + "_" + alumno.Apellido + "_" + DateTime.Now.ToString("dd MM yyyy") + ".xml", alumno))
                  {
                      seGuardo = true;
                  }
                  else
                  {
                      throw new ArchivoException("Error al Guardar el Archivo");
                  }
              }
              else
              {
                  string ruta = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\SegundoParcialUtn\JardinUtn\Desaprobados";

                  if (!Directory.Exists(ruta))
                  {
                      Directory.CreateDirectory(ruta);
                      throw new ArchivoException("Se creo directorio Desaprobados por que no existe");
                  }
                  if (archivo.GuardarArchivo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\SegundoParcialUtn\JardinUtn\Desaprobados\" + alumno.Nombre + "_" + alumno.Apellido + "_" + DateTime.Now.ToString("dd MM yyyy") + ".xml", alumno))
                  {
                      seGuardo = true;
                  }
                  else
                  {
                      throw new ArchivoException("Error al Guardar el Archivo");
                  }
              }
          }
          catch (ArchivoException ex)
          {
              Log.GuardarErrorExcepcion(ex);
          }


          return(seGuardo);
      }