예제 #1
0
        public void AddToFile(Alumno al)
        {
            //string path = @"C:\Users\enric.pedros\Desktop\alumnes.txt";
            string path = ConfigurationManager.AppSettings["ConfigPathTxt"].ToString();

            //string stringtoappend = al.Nombre + "," + al.Id + "," + al.Edad + "," + al.Dni + "," + al.Al_Guid;
            try
            {
                // File.AppendAllText(path, toappend); + Environment.NewLine

                if (File.Exists(path))
                {
                    using (StreamWriter strw = File.AppendText(path))
                    {
                        strw.WriteLine(al.ToString());
                    }
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
예제 #2
0
 public void Añadir(Alumno alumno)
 {
     using (StreamWriter sw = File.AppendText(Ruta))
     {
         sw.WriteLine(alumno.ToString());
     }
 }
예제 #3
0
파일: UI.cs 프로젝트: EnPeRe/AppVueling
        public static Alumno NewStudent()
        {
            Alumno al = null;
            string nom, dni;

            Console.WriteLine("Write the name:");
            nom = Console.ReadLine();
            Console.WriteLine("Write the id:");
            Int32.TryParse(Console.ReadLine(), out int id);
            Console.WriteLine("Write the age:");
            Int32.TryParse(Console.ReadLine(), out int age);
            Console.WriteLine("Write the dni:");
            dni = Console.ReadLine();
            al  = new Alumno(nom, age, id, dni);

            Console.WriteLine(al.ToString());
            return(al);
        }