I am trying to retrieve all the data in my isolated storage alarm.txt. The format of the data saved inside is like this not^no^home^apple^hao^how^.... and so on. And then i will put the split data "not" "no" "home" (3 by 3 and so on) into library items for data binding.
For my below code i only managed to get the first 3 data. What should i do to let it continue looping?
string[] alarmDetailsSeparated;
var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
try
{
StreamReader readFile = new StreamReader(new IsolatedStorageFileStream("AlarmFolder\\alarm.txt", FileMode.Open, myStore));
String fileText = readFile.ReadLine();
//alarmDetailsSeparated is the array that hold the retrieved alarm details from alarm.txt and is split by '^'
alarmDetailsSeparated = fileText.Split(new char[] { '^' });
ObservableCollection<Items> LibraryItems = new ObservableCollection<Items>();
for (int i = 0; i < alarmDetailsSeparated.Length; )
{
if (test > 0)
{
i = test;
}
//To add the alarmDetailsSeparated into the alarmListBox
dateSeparate = alarmDetailsSeparated[i];
timeSeparate = alarmDetailsSeparated[i + 1];
labelSeparate = alarmDetailsSeparated[i + 2];
date = dateSeparate;
time = timeSeparate;
label = labelSeparate;
test = test + 3;
break;
}
LibraryItems.Add(new Items(time, label));
alarmListBox.ItemsSource = LibraryItems;
}
catch (Exception)
{
}
if (alarmListBox.Items.Count == 0)
{
noAlarmTxtBlock.Visibility = Visibility.Visible;
}
}
}