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");