I am trying to encode my xml text using utf-8 with the code below. For some reason I am getting utf-16 instead of utf-8. Any reason why please?
StringWriter writer = new StringWriter();
xdoc.Save(writer);
writer.Flush();
string xml = writer.ToString();
byte[] bytes = Encoding.UTF8.GetBytes(xml);
System.IO.File.WriteAllBytes(pathDesktop + "\\22CRE002.XPO", bytes);