M
Markus Freitag
Guest
Hi,
protected void SaveTraceXML<T>(string file, T dataObject)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
using (Stream stream = new FileStream(file, FileMode.Create))
using (XmlWriter xmlWriter = XmlWriter.Create(stream, WriterSettingsExclusiv))
{
serializer.Serialize(xmlWriter, dataObject, Namespaces);
}
}
public static void WriteXml<T>(string filename, T template, XmlRootAttribute newRoot = null)
{
lock (LockObj)
{
FileStream fs = new FileStream(filename, FileMode.Create );
XmlSerializer xs = new XmlSerializer(typeof(T), newRoot);
xs.Serialize(fs, template);
fs.Close();
}
}
What is the difference between FileStream and file? When should I use what and when?
What are the advantages and disadvantages?
With best regards Markus
Continue reading...
protected void SaveTraceXML<T>(string file, T dataObject)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
using (Stream stream = new FileStream(file, FileMode.Create))
using (XmlWriter xmlWriter = XmlWriter.Create(stream, WriterSettingsExclusiv))
{
serializer.Serialize(xmlWriter, dataObject, Namespaces);
}
}
public static void WriteXml<T>(string filename, T template, XmlRootAttribute newRoot = null)
{
lock (LockObj)
{
FileStream fs = new FileStream(filename, FileMode.Create );
XmlSerializer xs = new XmlSerializer(typeof(T), newRoot);
xs.Serialize(fs, template);
fs.Close();
}
}
What is the difference between FileStream and file? When should I use what and when?
What are the advantages and disadvantages?
With best regards Markus
Continue reading...