Hi,
Seems, nothing wrong at first glance. However, I saw something that might be causing the exception.
You can change your code starting with the stream using the
using-statement.
See the code sample below.
using (StreamReader src = new StreamReader (new FileStream (filePath, FileMode.Open, FileAccess.Read)) {
while ((line = src.ReadLine ()) != null) {
RegistrationTrainingForm infoLst = new RegistrationTrainingForm ();
string[] info = line.Split (',');
infoLst.Country_Id = Convert.ToInt32 (info[0].ToString ());
infoLst.Country_Name = info[1].ToString ();
lst.Add (infoLst);
}
src.Close ();
src.Dispose ();
}
Hopefully, you can start with that code above and hope this helps.
Cheers,
Jin