I am using the following code to stream pptx which is in a MemoryStream object but when I open it I get Repair message in PowerPoint, what is the correct way of writing Memo
I had the same problem and the only solution that worked was:
Response.Clear();
Response.ContentType = "Application/msword";
Response.AddHeader("Content-Disposition", "attachment; filename=myfile.docx");
Response.BinaryWrite(myMemoryStream.ToArray());
// myMemoryStream.WriteTo(Response.OutputStream); //works too
Response.Flush();
Response.Close();
Response.End();
First We Need To Write into our Memory Stream and then with the help of Memory Stream method "WriteTo" we can write to the Response of the Page as shown in the below code.
MemoryStream filecontent = null;
filecontent =//CommonUtility.ExportToPdf(inputXMLtoXSLT);(This will be your MemeoryStream Content)
Response.ContentType = "image/pdf";
string headerValue = string.Format("attachment; filename={0}", formName.ToUpper() + ".pdf");
Response.AppendHeader("Content-Disposition", headerValue);
filecontent.WriteTo(Response.OutputStream);
Response.End();
FormName is the fileName given,This code will make the generated PDF file downloadable by invoking a PopUp.