下载后,打开的文件,提示格式出错? 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.netdocx

解决方案 »

  1.   


      byte[] bytes = new byte[1024];
      int count = 1;
                     try
                    {
                        while (count > 0)
                        {                        
                            count = stream.Read(bytes, 0, bytes.Length);                      
                            fileStream.Write(bytes, 0, count);
                        }
      

  2.   

    不是因为输出不完整,在IE10下是可以的,其他版本的IE就会出现这个问题,下载出错的文件长度比实际大,比较差异是多了<script>....的信息
      

  3.   

    strFiledata.Length 这个就是wend文档的实际长度,没有长度的问题,可能是http协议的问题,非常感谢