各位老大:
     小弟刚刚学会做下载,可以下dd了,但遇到部分可执行的文件如.mp3.asp.rm的
各位老大我要怎么做才能让他左键点击后可以下载呢

解决方案 »

  1.   

    to:dcren118(地狱黑客) 右键--》目标另寸
    客户不一定用这个啊
      

  2.   

    程序的大概如下:// aspx 页面
    <a href=DownloadFile.aspx?fileID=xxxxxx>点击下载</a>
    // DownloadFile.aspxvoid Page_Load(...)
    {
       ...
       // 向 Http 写回文件流
       response.ContentType = "application/x-download";
       response.AppendHeader("Content-Disposition", "attachment; FileName=" + HttpUtility.UrlEncode(fileName));
       response.BufferOutput = false;
       ...
       
       Stream fs = new FileStream("xxxx", ....);
       while (...)
       {
          fs.Read(buffer, 0, 4096);
          Response.OutputStream.Write(buffer, 0, 4096);  
       }   ....
       }
      

  3.   

    也就是你要自己控制文件的发送过程了,而不是简单地把连接重定向到物理文件链接上。发送文件时,首先要设置ContentType="application/x-download";这一点很重要;
    然后要添加Content-Disposition头,也就是response.AppendHeader("Content-Disposition", "attachment; FileName=" + HttpUtility.UrlEncode(fileName));这个也很重要,时关键的两步。
    最后就是循环读取文件内容并以二进制的方式写到 Response的 OutputStream 里了。