Search This Blog

Monday, September 3, 2018

Serialize C# DataTable

WriteToXml
Read Xml

When using WritetoXml, do use the overload that requires a file path and writes the xml schema (XmlWriteMode.WriteSchema).
ReadXml will throw an exception saying it does not support schema inference from xml.
In addition, don't forget to set the datatable name with the same name the datatable that was used to write to xml.