I m trying to retrieve all the data in the isolated storage file.
But i get a index out of range error.
home^how^yo^
StreamReader readFile = new StreamReader(new IsolatedStorageFileStream("AlarmFolder\\alarm.txt", FileMode.Open, myStore));
string[] alarmDetailsSeparated;
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[] { '^' });
foreach (string home in alarmDetailsSeparated)
{
for (i = 0; i < alarmDetailsSeparated.Length;)
{
if (test > 0)
{
i = test;
}
dateSeparate = alarmDetailsSeparated[i];
timeSeparate = alarmDetailsSeparated[i + 1];
labelSeparate = alarmDetailsSeparated[i + 2];
date = dateSeparate;
time = timeSeparate;
label = labelSeparate;
test = test + 3 ;
break;
}
MessageBox.Show("i is " + alarmDetailsSeparated[i]);
MessageBox.Show("i + 1 is " + alarmDetailsSeparated[i + 1]);
MessageBox.Show("i + 2 is " + alarmDetailsSeparated[i + 2]);
}
Ok, IIUC your storage file looks something like this:
and you want to do processing on each alarm data entry in the file.
The first thing you need to do is split it on each line:
Now you can do the split as you are doing in your code:
This should give you 4 entries if the line has the data you want, so check for this:
the data can now be extracted:
And then acted on: