static void Main(string[] args)
        {
            string appPath  = Environment.CurrentDirectory.ToString();
            string filePath = appPath + "\\XMLFILE1.xml";
            //Call the Menu
            MenuActions    newMenu  = new MenuActions();
            List <Student> students = newMenu.loadDB(filePath);

            if (args.Length == 0)
            {
                newMenu.diplayMenu(filePath, students);
            }
            else
            {
                switch (args[0])
                {
                case "n":
                    string thisName;
                    thisName = newMenu.GenCliName(students, filePath);
                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write(thisName);
                    Console.ForegroundColor = ConsoleColor.White;
                    ConsoleKeyInfo aKey = Console.ReadKey();
                    if (aKey.Key == ConsoleKey.Spacebar)
                    {
                        string[] thisArg = { "n" };
                        Main(thisArg);
                    }
                    Environment.Exit(0);
                    break;
                }
            }
        }
        public void ReadFile(string filePath, List <Student> students)
        {
            MenuActions newMenu = new MenuActions();

            string readThisData;

            Console.WriteLine("Attempting to read the file\n");
            if (File.Exists(filePath))
            {
                foreach (Student s in students)
                {
                    Console.WriteLine("Student ID: {0}| Name: {1} {2}| Times Called: {3}", s.StudentID, s.FirstName, s.LastName, s.TrackStudents);
                }
                readThisData = "";
            }
            else
            {
                readThisData = "File not found";
            }

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(readThisData);
            Console.WriteLine("\n\nPress any key to return to the menu...");
            Console.ReadKey();
            newMenu.diplayMenu(filePath, students);
        }
        public string GenCliName(List <Student> students, string filePath)
        {
            MenuActions newMenu     = new MenuActions();
            Random      rand        = new Random();
            int         thisStudent = rand.Next(students.Count);

            return(students[thisStudent].FirstName + " " + students[thisStudent].LastName);
        }
        public void GenName(List <Student> students, string filePath)
        {
            MenuActions newMenu     = new MenuActions();
            Random      rand        = new Random();
            int         thisStudent = rand.Next(students.Count);

            Console.WriteLine("Up next: {0} {1}", students[thisStudent].FirstName, students[thisStudent].LastName);
            Console.ReadKey();
            newMenu.diplayMenu(filePath, students);
        }
        static void Main(string[] args)
        {
            string  appPath  = Environment.CurrentDirectory.ToString();
            string  filePath = appPath + "\\names.txt";
            Student student1 = new Student();

            //Call the Menu
            MenuActions newMenu = new MenuActions();

            newMenu.diplayMenu(filePath, student1);
        }
        public void ReadFile(string filePath, Student student1)
        {
            MenuActions newMenu = new MenuActions();

            Console.WriteLine("Attempting to read the file\n");

            string readThisData = File.ReadAllText(filePath);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(readThisData);
            Console.WriteLine("\n\nPress any key to return to the menu...");
            Console.ReadKey();
            newMenu.diplayMenu(filePath, student1);
        }
        public void SaveFile(string filePath, List <Student> students, int options)
        {
            MenuActions newMenu = new MenuActions();

            //Build string to save the data
            Console.Write("\nAttempting to save data to file\n");
            //
            //Give some options to overwrite the existing file
            //
            switch (options)
            {
            case 1:
                TextWriter    writer     = new StreamWriter(filePath);
                XmlSerializer serializer = new XmlSerializer(typeof(List <Student>));
                serializer.Serialize(writer, students);
                writer.Close();

                if (File.Exists(filePath))
                {
                    Console.WriteLine("\nData updated\n\n");
                    Console.WriteLine("\n\nPress any key to continue...");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("Problem saving");
                    Console.WriteLine("\n\nPress any key to continue...");
                    Console.ReadKey();
                }
                break;

            case 2:
                File.AppendAllText(filePath, "");

                if (File.Exists(filePath))
                {
                    Console.WriteLine("\nData updated\n\n");
                    Console.WriteLine("\n\nPress any key to continue...");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("Problem saving");
                    Console.WriteLine("\n\nPress any key to continue...");
                    Console.ReadKey();
                }
                break;
            }
            newMenu.diplayMenu(filePath, students);
        }
        public void SaveFile(string filePath, Student student1, int options)
        {
            MenuActions newMenu = new MenuActions();

            //Build string to save the data
            string saveThisData = "Student ID: " + student1.StudentID + " Name: " + student1.FirstName + " " + student1.LastName + "\n";

            Console.Write("\nAttempting to save data to file\n");
            //
            //Give some options to overwrite the existing file
            //
            switch (options)
            {
            case 1:
                File.AppendAllText(filePath, saveThisData);

                if (File.Exists(filePath))
                {
                    Console.WriteLine("\nData updated\n\n");
                    Console.WriteLine("\n\nPress any key to continue...");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("Problem saving");
                    Console.WriteLine("\n\nPress any key to continue...");
                    Console.ReadKey();
                }
                break;

            case 2:
                File.WriteAllText(filePath, "");
                File.WriteAllText(filePath, saveThisData);
                if (File.Exists(filePath))
                {
                    Console.WriteLine("\nData saved\n\n");
                    Console.WriteLine("\n\nPress any key to continue...");
                    Console.ReadKey();
                }
                else
                {
                    Console.WriteLine("Problem saving");
                    Console.WriteLine("\n\nPress any key to continue...");
                    Console.ReadKey();
                }
                break;
            }
            newMenu.diplayMenu(filePath, student1);
        }