I am trying to do a check on the isolated storage followed by some command along with it.
What i wanted was to check for directories name consisting "a*" *If the directories exist* it will check if the diretory named after "a + today date" exist.
If it exist will show up a pop up message telling it does exist.
But if no directories consisting of "a*" is exist at all it will show a message of "Does not exist".
Below is my code:
- Is able to check if the directories exist when there is a directory of "a*" is created.
- But it does not work *when none of the directories "a" is created**. How should i modify my code?
Code:
string[] fileNames;
string selectedFolderName;
private void gameBtn_Click(object sender, RoutedEventArgs e)
{
//MediaPlayer.Stop();
string currentDate = DateTime.Now.ToString("MMddyyyy");
string currentDateName = "a" + currentDate;
IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
fileNames = myStore.GetDirectoryNames("a*");
foreach (var name in fileNames)
{
if (fileNames.Contains(currentDateName))
{
selectedFolderName = currentDateName;
MessageBox.Show("Your schedule for today");
NavigationService.Navigate(new Uri("/DisplaySchedule.xaml?selectedFolderName=" + selectedFolderName, UriKind.Relative));
}
else
{
MessageBox.Show("No Schdule for today", "Schedule Reminder", MessageBoxButton.OK);
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
}
}
}