0
我用它来保存分数每次游戏结束我尝试使用WP7中的独立存储在txt文件中保存很多行,但它只会保存一个,如何保存很多?
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
isf.CreateDirectory("Data");
StreamWriter sw = new StreamWriter(new IsolatedStorageFileStream("Data\\scoretest.txt", FileMode.Create, isf));
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm") + " Score: " + punc);
sw.Close();
,并从TXT阅读我用的时候阅读是空
IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
StreamReader sr = null;
try
{
sr = new StreamReader(new IsolatedStorageFileStream(@"Data\scoretest.txt", FileMode.Open, isf));
for (;;)
{
string x = sr.ReadLine();
if (x == null)
break;
else
listBox1.Items.Add(x);
}
sr.Close();
}
catch
{
listBox1.Items.Add("");
}
它只收取最后一个为停止行,为什么它不读取多行?