Okay so I'm making an app for windows 8 store, but I'm using MessageDialog for errors I'm not particularly sure why but it seems that when I include the MessageDialog the foreach loop stops looping through every single line and looking at the first line only, so here's my code;
try {
StorageFolder folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
StorageFile storageFile = await folder.GetFileAsync("students.txt");
var text = await Windows.Storage.FileIO.ReadLinesAsync(storageFile);
foreach (var line in text)
{
string name = "" + line.Split('|')[0];
string testTaken = "" + line.Split('|')[1];
if (your_name.Text == name)
{
if (testTaken == "false")
{
pageTitle.Text = name + "'s test";
enter_name_grid.Opacity = 0;
questions_grid.Opacity = 1;
var md = new MessageDialog("Enjoy the test");
await md.ShowAsync();
}
else
{
var md1 = new MessageDialog("You have already taken the test");
await md1.ShowAsync();
}
}
else
{
pageTitle.Text = "Test";
var md2 = new MessageDialog("You're not on the list");
await md2.ShowAsync();
}
}
} catch (Exception e) {
var mderror = new MessageDialog("{0} Exception caught: " + e);
mderror.ShowAsync();
}
I have really hit a dead end with this now so anyone that can shed some light or give any help, it would be appreciated! thanks