Why are .docx files being corrupted when downloading from an ASP.NET page?

前端 未结 8 971
长发绾君心
长发绾君心 2020-12-03 05:09

I have this following code for bringing page attachments to the user:

private void GetFile(string package, string filename)
{
    var stream = new MemoryStre         


        
8条回答
  •  天涯浪人
    2020-12-03 05:26

    You should not use stream.GetBuffer() because it returns the buffer array which might contain unused bytes. Use stream.ToArray() instead. Also, have you tried calling stream.Seek(0, SeekOrigin.Begin) before writing anything?

    Best Regards,
    Oliver Hanappi

提交回复
热议问题