How should I handle this situation?
I set the Encoding to UTF8 but I still get errors...
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);
}
精彩评论