BaseUtil.cs 879 B

123456789101112131415161718192021222324252627
  1. using System.IO;
  2. using System.Xml;
  3. namespace UAS_AutoPass.ToolClass
  4. {
  5. class BaseUtil
  6. {
  7. public static void CreateXml(string iSN, string iTestResult)
  8. {
  9. //创建XML文档
  10. FileStream fcaches = new FileStream(iSN + ".xml", FileMode.OpenOrCreate, FileAccess.ReadWrite);
  11. fcaches.Close();
  12. FileInfo info = new FileInfo(iSN + ".xml");
  13. if (info.Length == 0)
  14. {
  15. XmlDocument doc = new XmlDocument();
  16. //创建类型声明节点
  17. XmlNode node = doc.CreateXmlDeclaration("1.0", "utf-8", "");
  18. doc.AppendChild(node);
  19. //创建根节点
  20. XmlElement xeRoot = doc.CreateElement("cacheInfo");
  21. doc.AppendChild(xeRoot);
  22. doc.Save(iSN + ".xml");
  23. }
  24. }
  25. }
  26. }