/// <summary>
        /// 创建xml文件
        /// </summary>
        /// <param name="xmlDoc">xml</param>
        /// <returns></returns>
        public string CreateXml(string xmlDoc)
        {
            string filePathName = string.Empty;
            try
            {

                if (Directory.Exists(XMLPath) == false)
                {
                    Directory.CreateDirectory(XMLPath);
                }
                string t1 = "GL";
                string t2 = Convert.ToDateTime(DateTime.Now.ToString()).ToString("yyyyMMddHHmmss");
                string t3 = DateTime.Now.Millisecond.ToString();
                string NewFileName = t1 + t2 + t3 + ".xml";
                filePathName = XMLPath + "\\" + NewFileName;
                XmlDocument XmlDocument = ConvertStringToXml(xmlDoc);
                StreamWriter sw = new StreamWriter(filePathName, false, new UTF8Encoding(false));
                XmlDocument.Save(sw);
                sw.Close();
                bool m_isFileExisted = File.Exists(filePathName);
                if (m_isFileExisted)
                {
                    return filePathName;
                }
                else
                {
                    filePathName = "";
                }
            }
            catch (Exception ex)
            {
                filePathName = "";
            }
            return filePathName;
        }

 

相关文章:

  • 2021-12-26
  • 2021-12-07
  • 2022-12-23
  • 2022-01-25
  • 2022-12-23
  • 2021-10-29
  • 2022-01-30
猜你喜欢
  • 2021-08-25
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2022-03-02
相关资源
相似解决方案