Catch bad file, invalid csv, etc.

This commit is contained in:
Tim Young 2017-08-01 14:45:38 -05:00
parent 405fe94953
commit f749914338

View File

@ -414,6 +414,8 @@ namespace EduNetworkBuilder
//Now we have a csv file. Try to parse it //Now we have a csv file. Try to parse it
bool HadError = false; bool HadError = false;
try
{
using (TextFieldParser parser = new TextFieldParser(mydialog.FileName)) using (TextFieldParser parser = new TextFieldParser(mydialog.FileName))
{ {
parser.TextFieldType = FieldType.Delimited; parser.TextFieldType = FieldType.Delimited;
@ -460,13 +462,18 @@ namespace EduNetworkBuilder
tList.Add(TStudent); tList.Add(TStudent);
} }
} }
if(HadError) if (HadError)
{ {
ShowInvalid("Username", InvalidUsers); ShowInvalid("Username", InvalidUsers);
ShowInvalid("Full Name", InvalidFullName); ShowInvalid("Full Name", InvalidFullName);
ShowInvalid("Password", InvalidPasswords); ShowInvalid("Password", InvalidPasswords);
} }
} }
catch (Exception except)
{
MessageBox.Show(except.ToString());
}
}
private void ShowInvalid(string What, List<string> BadUsers) private void ShowInvalid(string What, List<string> BadUsers)
{ {