BlaBlub: Text in UTF-8 speichern

Beitrag lesen

Hallo,

                    System.IO.Stream fileStream;  
  
                    System.IO.MemoryStream userInput = new System.IO.MemoryStream();  
  
                    XmlDocument doc = new XmlDocument();  
                    XmlNode myRoot, myNode;  
  
                    myRoot = doc.CreateElement("test");  
                    doc.AppendChild(myRoot);  
  
                    for (int i = 0; i <= a; i++)  
                    {  
                        myNode = myRoot.AppendChild(doc.CreateElement("node"));  
                        myRoot.SelectNodes("node").Item(i).Attributes.Append(doc.CreateAttribute("param")).InnerText = i.ToString();  
  
                    }  
  
                    doc.Save(userInput);  
  
                    fileStream = saveFileDialog1.OpenFile();  
  
                    userInput.Position = 0;  
                    userInput.WriteTo(fileStream);

ich generiere ein XML-Dokument und speichere es. Es wird aber ANSI-codiert gespeichert. Wenn ich es dann manuell mit Notepad öffne und UTF-8 codiert abspeichere, kann ich es in meinem weiterem Programmcode nutzen.
Wie bekomme ich es hin, dass er gleich als UTF-8 speichert?

Gruß

BlaBlub