我需要像<numbers>12345</numbers>
这样的真实输出。但序列化后文件为空。这是我的代码:
public string Numbers { get; set; }
按钮点击事件:
private void Ref_Clicked(object sender, RoutedEventArgs e)
{
Item puz = new Item();
puz.Numbers = "12345";
Save(puz);
}
序列化功能:
public static void Save(Item settings)
{
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
XmlSerializer ser = new XmlSerializer(typeof(Item));
using (IsolatedStorageFileStream isoStream = store.OpenFile(@"data.xml", System.IO.FileMode.Create))
{
try
{
ser.Serialize(isoStream, settings);
}
catch (Exception)
{ }
isoStream.Close();
}
}
}