DataTable转xml存储到日志

public static void DataTableToXml(DataTable mydt, string Filename)
{
      string directory = System.Web.Hosting.HostingEnvironment.MapPath(@"~/") + "\\log\\"+ DateTime.Now.ToString("yyyyMMdd")+"\\";
      System.IO.Directory.CreateDirectory(directory);
      System.IO.FileStream streamWrite = new System.IO.FileStream
      (directory+ Filename, FileMode.OpenOrCreate);
      mydt.WriteXml(streamWrite, XmlWriteMode.WriteSchema);
}
DataTableToXml(dataTable,“log1.log");

 

posted @ 2020-01-05 10:59  zhaogaojian  阅读(248)  评论(0编辑  收藏  举报