Save HTML in string

I am converting a Word document to HTML. Is it possible to save the output in a string instead of a file?
Thanks,
Andreas

Hi
Thanks for your inquiry. I think that you can use the following code to achieve this.

// Save document as HTML into memory stream
MemoryStream htmlStream = new MemoryStream();
doc.Save(htmlStream, SaveFormat.Html);
// Get html string
string html = Encoding.UTF8.GetString(htmlStream.GetBuffer());

Hope this helps.
Best regards.

1 Like