Good morning everyone. I wrote a very simple class in C# that generates an html file and return it in a string. I want to write a new class that will display this file in default browser. Could you tell me how can I do it?
public class Class1
{
public string HTMLGen(int number)
{
var html = string.Format("<p>testing my {0} html code</p>", number);
var xDocument = new XDocument(
new XDocumentType("html", null, null, null),
new XElement("html",
new XElement("head"),
new XElement("body",
XElement.Parse(html)
)
)
);
var settings = new XmlWriterSettings
{
OmitXmlDeclaration = true,
Indent = true,
IndentChars = "\t"
};
using (var sw = new StringWriter())
{
using (var writer = XmlWriter.Create(sw, settings))
{
xDocument.WriteTo(writer);
}
return sw.ToString();
}
}
}