我想要檢索我孤立的存儲alarm.txt中的所有數據。 裏面保存的數據格式就是這樣不是^ no^home^apple^hao ^怎麼^ ......等等。 然後我會將分割數據「不」,「不」,「家」(3乘3等等)放入用於數據綁定的庫項目中。從孤立的存儲窗口檢索數據電話7
對於我的下面的代碼,我只設法得到前3個數據。 我該怎麼做讓它繼續循環?
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;
}
}
}
對不起,但你有沒有想過使用XML而不是這個極端ulgy「不^ ^家^蘋果^好^如何^ ...「自定義格式? – CodeZombie
嗯如何去做呢? –
請參閱http://stackoverflow.com/questions/6663607/reading-complex-xml-in-c-windows-phone –