I read XML from WCF and I need to save the XML to my disk but I get a BOM character when I save it. I don't want this character included, so I tried different ways to write the document without it, but it is not working, I don't know what is wrong. Any idea?
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(vReply.xmlDocumento);
////-------------------------- Save without BOM  -----------------------
var bytes = Encoding.UTF8.GetBytes(vReply.xmlDocumento);
var stream = new MemoryStream(bytes);
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = new UTF8Encoding(false); // The false means, do not emit the BOM.
using (XmlWriter w = XmlWriter.Create("c://temp/my.xml", settings))
{
xmlDoc.Save(w);
}