using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace RoboticsClub { class Program { static void Main(string[] args) { // Open "Members.input" for input Console.Out.Write("Attempting to load 'Members.input'... "); TextReader input = null; try { input = new StreamReader("Members.input"); } catch(System.IO.IOException error) { // Quit Console.Out.WriteLine("Failed to load 'Members.input': " + error.Message); return; } Console.Out.WriteLine("Done!"); // Open "Members.output" for output Console.Out.Write("Attempting to load 'Members.output'... "); TextWriter output = null; try { output = new StreamWriter("Members.csv", false); } catch (System.IO.IOException error) { // Quit Console.Out.WriteLine("Failed to open 'Members.output': " + error.Message); return; } Console.Out.WriteLine("Done!"); // Format the top of list output.WriteLine("Full name, User ID, EMail, Major, Year"); // For each line in the input String UserID; while ((UserID = input.ReadLine()) != null) { // Validate the line (Either it's a "[jgb5034]@psu.edu" or a "PSU ID: [jgb5034]" // All else is junk if (UserID.Contains('@')) { int AtIndex = UserID.IndexOf('@'); UserID = UserID.Substring(0, AtIndex); } else if(UserID.Contains("PSU ID: ")) { UserID = UserID.Substring("PSU ID: ".Length); } else continue; // Read the user ID and load the user ID information Console.Out.Write("Processing " + UserID + ".... "); PersonalPage User = new PersonalPage(UserID); // Write out data if (!User.ErrorBool) { output.WriteLine(User.FullName + ", " + User.ID + ", " + User.EMail + ", " + User.Major + ", " + User.Year); Console.Out.WriteLine("Done!"); } else Console.Out.WriteLine("Unable to query: " + User.ID + ". Error: " + User.ErrorString); } Console.Out.WriteLine("Finished processing!"); // Close both streams input.Close(); output.Close(); } } }