无法序列化为xml文件 [英] Can't serialize to xml File
问题描述
XmlSerializer xS = new XmlSerializer(myProfile.GetType());
StreamWriter sW = new StreamWriter(" /myProfile.xml");
xS.Serialize(sW.BaseStream,myProfile);
亲爱的Windows手机开发社区,
我对此代码有疑问。
我想将对象保存在XML文件中。
我想写的XML文件位于同一个Project中,他总是说异常"'System.UnauthorizedAccessException"。
感谢您的帮助。
在Windows Phone中,您必须将文件保存在独立存储中。尝试以下链接中的代码
http://www.geekchamp.com/tips/all-about-wp7-isolated-storage---read-and-save-xml-files
http://blogs.msdn .com / b / dawate / archive / 2010/08/31 / windows-phone-7-xml-isolatedstorage-example.aspx
XmlSerializer xS = new XmlSerializer(myProfile.GetType()); StreamWriter sW = new StreamWriter("/myProfile.xml"); xS.Serialize(sW.BaseStream, myProfile);
Dear Windows phone dev community,
i have a Problem with this code.
I want to save the object in a XML file.
The XML file to which I want to write is in the same Project and he always says that exception "'System.UnauthorizedAccessException".
Thanks for your help.
In Windows Phone you have to save the file in Isolated Storage. Try code in following links
http://www.geekchamp.com/tips/all-about-wp7-isolated-storage---read-and-save-xml-files
http://blogs.msdn.com/b/dawate/archive/2010/08/31/windows-phone-7-xml-isolatedstorage-example.aspx
这篇关于无法序列化为xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!