如果文件存在服务器上,直接在页面<a href="相对路径/文件名.rar">asp教程下载</a>
存在数据库里的文件需要打开数据源通过参数来传递

解决方案 »

  1.   

    我也是最近才找的。给你代码吧.public void download()
        {
            string path = Server.MapPath(@"需要下载文件的地址(服务器端的)");
            //下载文件的名称
            string filename = "c.doc";
            System.IO.FileInfo toDownload = new System.IO.FileInfo(path);        if (toDownload.Exists == true)
            {
                const long ChunkSize = 10000;
                byte[] buffer = new byte[ChunkSize];            Response.Clear();
                System.IO.FileStream iStream = System.IO.File.OpenRead(path);
                long dataLengthToRead = iStream.Length;
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition", "attachment; filename=new_" + HttpUtility.UrlEncode(toDownload.Name));
                while (dataLengthToRead > 0 && Response.IsClientConnected)
                {
                    int lengthRead = iStream.Read(buffer, 0, Convert.ToInt32(ChunkSize));
                    Response.OutputStream.Write(buffer, 0, lengthRead);
                    Response.Flush();
                    dataLengthToRead = dataLengthToRead - lengthRead;
                    Response.WriteFile(filename);
                }
                Response.Close();
            }
        }
      

  2.   

    唉,还是感觉有点难啊!~~~~(>_<)~~~~ 
      

  3.   

    Response.Redirect("URL")
    <a herf = "URL"></a>
    Response.Write("<script>window.open('URL')</script>")
    不过以上都是系统自带的,用的是单线程
    如果使用频率少,切文件相对较小,可以用以上方法.如果使用频率较多,
    就使用多线程断点下载,就去网上找找吧,现成的一大堆,只需调用就行了
      

  4.   

    用到了字节流,有点深,依我看还是用<a href="相对路径/文件名.rar">asp教程下载 </a>简单,数据库方面连上地址(最好是物理地址,不容易出错)就OK了!