当我尝试反序列化流时发生错误。
public static AllFlags Load()
{
IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
AllFlags allFlags;
//IsolatedStorageFileStream stream = storage.OpenFile(filename, FileMode.Open);
StringReader stream = new StringReader(filename);
XmlSerializer xml = new XmlSerializer(typeof(AllFlags));
allFlags = xml.Deserialize(stream) as AllFlags;// here There is an error in XML
stream.Close();
stream.Dispose();
return allFlags;
}
如果我从隔离存储打开文件没问题
public static AllFlags Load()
{
IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
AllFlags allFlags;
IsolatedStorageFileStream stream = storage.OpenFile(filename, FileMode.Open);
XmlSerializer xml = new XmlSerializer(typeof(AllFlags));
allFlags = xml.Deserialize(stream) as AllFlags;
stream.Close();
stream.Dispose();
return allFlags;
}
我怎样才能打开这个文件?
编辑:
我的 xml 文件“Flags.xml”:
<?xml version="1.0"?>
<AllFlags>
<Flags>
<Flag>
<Tag>Tag1</Tag>
<Name>Name1</Name>
</Flag>
...
</Flags>
</AllFlags>