I\'m using serialization and deserialization in C# for my Project (which is a Class). They are serialized and saved to an XML file. When loading the Project, all goes well.<
Rather than having to worry about encoding, perhaps just use XmlWriter.Create(outPath), and pass that XmlWriter to your serialization code. That will avoid this issue, and other issues (such as having to buffer very large strings for large object graphs). There is an overload that accepts an XmlWriterSettings for finer control.
XmlWriter is accepted by most xml code.