开发者

How to handle Illegal Chars in XML

How should I handle this situation?

I set the Encoding to UTF8 but I still get errors...

How to handle Illegal Chars in XML

I create that string (that I set to the WebBrowser.DocumentText) from a Mem开发者_运维知识库oryStream object and I'm ending it like this:

Byte[] buffer = new Byte[ms.Length];
buffer = ms.ToArray();
return System.Text.Encoding.UTF8.GetString(buffer);

What am I missing?


You're passing the XML string as a filename.

You probably want to write

File.WriteAllText(saveFileDialog.FileName, wb.DocumentText);

Or, alternatively,

using(StreamWriter writer = new StreamWriter(saveFileDialog.OpenFile(), false, Encoding.UTF8)) {
    write.Write(wb.DocumentText);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜