string LocalPath="H:/ERPtest_FTP/"+TheFtpType+"/"+Theremotepath+"/";
string TheName=LocalPath+LocalFileName;
string TN=LocalFileName;
string TT="Content-Disposition";
string TV="attachment;filename="+HttpContext.Current.Server.UrlEncode(Request.QueryString["strFilename"].ToString());Response.AddHeader(TT,TV);  
Response.WriteFile(TheName); 用如上代码下载。当格式为PDF文件时,下载下来的总比原来文件大约2K。所以打开会出错。但JPG,Xls不会。
请问怎么解决。
在线等.....

解决方案 »

  1.   

    在你自己的代碼裡加入這一句:
    Response.AddHeader("Content-Length", DownloadFile.Length.ToString()););  或用這種方式:
    private void FileDownload()
        {
            String FullFileName = Server.MapPath("文件路径");
            FileInfo DownloadFile = new FileInfo(FullFileName);
            Response.Clear();
            Response.ClearHeaders();
            Response.Buffer = false;
            Response.ContentType = "application/octet-stream";
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
            Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
            Response.WriteFile(DownloadFile.FullName);
            Response.Flush();
            Response.End();
        }