Load调用方法 Create_Xml(Create_XML_Name());
public static string filePath = Application.StartupPath + "/XML/"; //存放XML文件的地址,Bin/Debug/XML文件夹
private string Create_XML_Name()
{
if (!Directory.Exists(filePath))
Directory.CreateDirectory(filePath);
return (filePath + "文件名称" + ".xml");
}
private static void Create_Xml(string xmlPath)
{
XmlTextWriter writer = new XmlTextWriter(xmlPath,null);
//使用自动缩进便于阅读
writer.Formatting = Formatting.Indented;
writer.WriteStartElement("Manifest"); //写入根元素Manifest
writer.WriteStartElement("Head"); //打开根元素Head,并书写开始标签
writer.WriteElementString("MessageID","编号"); //编号
writer.WriteElementString("DateTime",""); //时间
writer.WriteElementString("Version",""); //版本号
writer.WriteEndElement(); //关闭根元素Head,并书写结束标签
writer.WriteStartElement("Declaration");//写入根元素Declaration
writer.WriteEndElement(); //关闭根元素Declaration
writer.WriteEndElement(); //关闭根元素Manifest
writer.Close();
}