当前位置:编程学习 > C#/ASP.NET >>

asp.net实线docx下载出错

下载后,打开的文件,提示格式出错?

 Response.Clear();
            Response.ClearHeaders();
            Response.ClearContent();
            Response.Buffer = true;
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.AppendHeader(@"Content-Disposition", @"attachment;filename=" + HttpUtility.UrlEncode(strFileName, System.Text.Encoding.UTF8));
            Response.AddHeader("Content-Length", (strFiledata.Length).ToString());
            Response.ContentType = strContentType;
            Response.OutputStream.Write(strFiledata, 0, strFiledata.Length);
            Response.Flush();
            Response.End(); asp.net docx --------------------编程问答-------------------- 说明你下载的文件不完整,文件流里的东西没完全输出~~~~ 
输出要写循环的~~~ --------------------编程问答--------------------

  byte[] bytes = new byte[1024];
  int count = 1;
                 try
                {
                    while (count > 0)
                    {                        
                        count = stream.Read(bytes, 0, bytes.Length);                      
                        fileStream.Write(bytes, 0, count);
                    }
--------------------编程问答-------------------- 不是因为输出不完整,在IE10下是可以的,其他版本的IE就会出现这个问题,下载出错的文件长度比实际大,比较差异是多了<script>....的信息 --------------------编程问答-------------------- strFiledata.Length 这个就是wend文档的实际长度,没有长度的问题,可能是http协议的问题,非常感谢
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,