Expand|Select|Wrap|Line Numbers
- /*
- * Process of exporting file to save it as a single document, ensuring
- * that the correct extension is used.
- */
- private void ExportToSave(string path, string fileContent)
- {
- HttpResponse hr = HttpContext.Current.Response;
- hr.AddHeader("Content-Disposition", "attachment;filename=ProRefExport");
- StreamWriter sw = new StreamWriter(path);
- HtmlTextWriter htmlWriter = new HtmlTextWriter(sw);
- sw.WriteLine(string.Format("Generated by user on", DateTime.Today));
- sw.Close();
- htmlWriter.Close();
- File.WriteAllText(path, fileContent, System.Text.Encoding.ASCII);
- hr.ContentType = "text/html";
- hr.End();
- base.Render(htmlWriter);
- }
I tried writing the fileContent string as an array of bytes using the same StreamReader object I created but made things worse as I had file process errors.
Why might this be and what can I do to solve this problem?