/// <summary>
         /// 将XML字符串写入到XML文件
         /// </summary>
        /// <param name="strXML"></param>
        private int WriteStrToXML(string strXmlName, string strXML)
        {
            try
            {
                string filepath = System.Web.HttpContext.Current.Server.MapPath("~/CatXML");
                if (!Directory.Exists(filepath))
                    Directory.CreateDirectory(filepath);
                filepath = filepath + "/" + DateTime.Now.ToString("yyyy-MM-ddHHmmss") + strXmlName + ".XML";
                XmlDocument xdoc = new XmlDocument();
                xdoc.AppendChild(xdoc.CreateXmlDeclaration("1.0", "UTF-8", null));//xml文件头
                xdoc.LoadXml(strXML);
                xdoc.Save(filepath);
                return 0;
            }
            catch (Exception)
            {
                return -1;
            }
        }

 

相关文章:

  • 2021-10-26
  • 2022-12-23
  • 2021-12-19
  • 2021-12-08
  • 2022-12-23
  • 2022-02-13
猜你喜欢
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-26
  • 2022-01-21
相关资源
相似解决方案