Writing MemoryStream to Response Object

后端 未结 8 1530
闹比i
闹比i 2020-11-27 20:03

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

8条回答
  •  青春惊慌失措
    2020-11-27 20:43

    Try with this

    Response.Clear();
    Response.AppendHeader("Content-Type", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
    Response.AppendHeader("Content-Disposition", string.Format("attachment;filename={0}.pptx;", getLegalFileName(CurrentPresentation.Presentation_NM)));
    Response.Flush();                
    Response.BinaryWrite(masterPresentation.ToArray());
    Response.End();
    

提交回复
热议问题