我为Windows 10移动版编写UWP应用.
我创建了这样的xml:
XmlDocument doc = new XmlDocument();
XmlElement el = (XmlElement)doc.AppendChild(doc.CreateElement("Order"));
el.SetAttribute("CallConfirm", "1");
el.SetAttribute("PayMethod", "");
el.SetAttribute("QtyPerson", "");
el.SetAttribute("Type", "1");
el.SetAttribute("PayStateID", "0");
el.SetAttribute("Remark", "{StreetName} , ..");
el.SetAttribute("RemarkMoney", "0");
el.SetAttribute("TimePlan", "");
el.SetAttribute("Brand", "1");
el.SetAttribute("discountPercent", "0");
el.SetAttribute("BonusAmount", "0");
el.SetAttribute("Department", "");
XmlElement el2 = (XmlElement)el.AppendChild(doc.CreateElement("Customer"));
el2.SetAttribute("Login", "");
el2.SetAttribute("FIO", "{FIO}");
XmlElement el3 = (XmlElement)el.AppendChild(doc.CreateElement("Address"));
el3.SetAttribute("CityName", "");
el3.SetAttribute("StationName", "");
el3.SetAttribute("StreetName", "{StreetName}");
el3.SetAttribute("House", "{HouseName}");
el3.SetAttribute("Corpus", "");
el3.SetAttribute("Building", "");
el3.SetAttribute("Flat", "{FlatName}");
el3.SetAttribute("Porch", "");
el3.SetAttribute("Floor", "");
el3.SetAttribute("DoorCode", "");
XmlElement el4 = (XmlElement)el.AppendChild(doc.CreateElement("Phone"));
el4.SetAttribute("Code", "{Code}");
el4.SetAttribute("Number", "{Phone}");
XmlElement el5 = (XmlElement)el.AppendChild(doc.CreateElement("Products"));
我想创建.xml文件并将此xml写入其中.
我尝试将其保存为doc.Save(“ data.xml”);但是有这个错误
Error CS1503 Argument 1: cannot convert from 'string' to 'System.IO.Stream' Murakami
我该怎么做?
非常感谢您的帮助!
解决方法:
由于您正在编写Windows 10通用应用程序,因此XmlDocument.Save(string)不可用.相反,使用
using (FileStream fs = new FileStream("test.xml", FileMode.Create))
{
doc.Save(fs);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。