0
我正在申請一個'滑雪勝地',您可以在其中添加成員和搜索成員等等。到目前爲止,我在應用程序關閉時無法保存和加載這些應用程序。當我添加一個成員時,它會保存,然後當我嘗試添加另一個成員時,第一個成員將不再保存,但第一個成員已經完成。 這裏是用來保存成員的代碼:麻煩保存C#WPF
public void Save(System.IO.TextWriter textOut)
{
textOut.WriteLine(number);
textOut.WriteLine(name);
textOut.WriteLine(address);
textOut.WriteLine(score);
textOut.Close();
}
public bool Save(string filename)
{
System.IO.TextWriter textOut = null;
try
{
textOut = new System.IO.StreamWriter(filename);
Save(textOut);
}
catch
{
return false;
}
finally
{
if (textOut != null)
{
textOut.Close();
}
}
return true;
}