请教一个问题要做一个下载的功能 文件格式很多种 例如 txt docx xls zip rar pdf 等 现在预见一个问题.如果是文本文件等能直接打开不能出来下载窗口.我还不在内存中压缩成包在下载.有没有好办法 解决这个下载问题任何类型的文件都弹出下载框

解决方案 »

  1.   

    我现在就是这么做的.可是把内容读出来输出到页面中了.
    Path = myFile.GetPhysicalPath(Directory)
                Path = Path & FileName
                Dim File As New FileInfo(Path)
                Response.Clear()
                Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(File.Name))
                Response.AddHeader("Content-Length", File.Length.ToString)
                Response.WriteFile(File.FullName)
                Response.End()
      

  2.   


    找到原因为什么不可以了。因为ajax方式 已经输出头来了。用location.href不OK了