I have a function that writes a html file and opens it to a web browser. However when I package and deploy the application it will not open and says access denied. I am told I need to write the html file to the computers mydocuments and open it there. Any ideas on how to do this so I can get around this permission error? Here is my function that writes the html file:
private void PrintReport(StringBuilder html)
{
// Write (and overwrite) to the hard drive using the same filename of "Report.html"
try
{
// A "using" statement will automatically close a file after opening it.
// It never hurts to include a file.Close() once you are done with a file.
using (StreamWriter writer = new StreamWriter("Report.html"))
{
writer.WriteLine(html);
}
System.Diagnostics.Process.Start(@"Report.html"); //Open the report in the default web browser
}
catch (Exception ex)
{
MessageBox.Show(message + ex.Message, "Program Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}