嗨,我尝试了一切:D 我在Windows应用程序中尝试反序列化file.xml几次时遇到问题。求助于帮助:) Windows 8应用程序 当我有菜单时,我有MainPage
我回到MainPage,我想再次显示来自同一个文件的数据,但现在我什么都不读,我的意思是'单词不包含数据
DESERIALIZATION
StorageFile sessionFile;
var serializer = new XmlSerializer(typeof(List<word>));
words = new List<word>();
try
{
if (await XMLModifier.IsFileExists(XMLModifier.wordsContainter, ApplicationData.Current.LocalFolder) == true)
{
sessionFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(XMLModifier.wordsContainter, CreationCollisionOption.OpenIfExists);
IInputStream sessionInputStream = await sessionFile.OpenReadAsync();
words = (List<word>)serializer.Deserialize(sessionInputStream.AsStreamForRead());
sessionInputStream.Dispose();
}
else
{
string data = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year;
word w = new word("Base is empty", "Base is empty", data, 0, 0, 0);
words.Add(w);
}
}
catch (Exception e)
{
..............
}