First, as SAKryukov said, there is no need to convert to a byte array, although you might like to buffer using a byte array. The
SaveFileDialog
takes no part writing the file, other than providing a convenient way to create a stream. Get rid of your 1
st if
statement and change the following:
using (Stream output = dialog.OpenFile())
{
provider.Export(document, output);
}
to:
using (Stream output = new FileStream(@"c:\foo.html",FileMode.Whatever, FileAccess.Whatever)
{
provider.Export(document, output);
}
Note that I've used a magic string for the filepath, this is bad and you need to replace it with your filename string. You also need to determine which
FileMode
and
FileAccess
types you need:
FileMode[
^]
FileAccess[
^]