views:

42

answers:

1

How should I handle this situation?

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

alt text

I create that string (that I set to the WebBrowser.DocumentText) from a MemoryStream 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?

+3  A: 

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);
}
SLaks
:o( Dang, I need a break, I'm to tired !!! thank you for spotting it.
balexandre