private void WriteItemsToXMLFile<T>(T item, string fileName)
{
try
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
XmlTextWriter textWriter = new XmlTextWriter(fileName, Encoding.UTF8);
//Set formatting options:
textWriter.Formatting = Formatting.Indented; //Intented formatting
textWriter.Indentation = 4; //Use the size of a tab to intent
xmlSerializer.Serialize(textWriter, item);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Keine Kommentare:
Kommentar veröffentlichen