110,533
社区成员
发帖
与我相关
我的任务
分享
XElement doc = XElement.Load(Application.StartupPath + "\\Buffer\\OK.xml");//把OK文件的xml读出来
XElement b = new XElement("BatteryItem",
new XElement("ID", bi.id),
new XElement("Barcode", bi.barcode),
new XElement("Press", bi.press),
new XElement("Temperature1", bi.temperature1),
new XElement("Temperature2", bi.temperature2),
new XElement("Vacuum", bi.vacuum)
);//把bi转化为xml形式的子元素
doc.Add(b);//b加入自动xml元素中
doc.Save(Path.Combine(Application.StartupPath,"\\Buffer\\OK.xml"));//将数据写入指定的文件中并且覆盖
File.Copy(Application.StartupPath + "\\Buffer\\OK.xml", Application.StartupPath + "\\Buffer\\OKBak.xml", true);