比如我d:下有一个文件“AA”,我该如何通过按钮点击,然后在WEB页面上弹出那种打开保存界面供用户下载这个文件?

解决方案 »

  1.   

    protected void Download_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                string url = this.Server.MapPath(this.DrivePath);
                string fielName = this.DrivePath.Substring(this.DrivePath.LastIndexOf("//") +2);
                //Response.Write("<script>alert('daf');</script>");
                //this.lblMessage.Text = url + "aaa" + fielName;
                long speed = UtilTool.ToSafeInt32(ConfigurationManager.AppSettings["Speed"]);
                bool download = new DownLoad().ResponseFile(this.Request,this.Response,fielName,url,speed);
                //if (download)
                //{
                //    this.lblMessage.Text = "11111111111111111111111111111111111111111111111111111!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
                //    Response.Write("<script>alert('下载完成!');window.opener = null;window.close();</script>");
                //    Response.Write("<script>alert('成功!!');</script>");
                //}
            }
            catch (Exception ex)
            {
                this.lblMessage.Text = ex.Message;
            }
        }
    点击后自己就出现保存到那里。 有可能你安装的下载软件也就出来。自己选用那个下载
      

  2.   

    你贴的这个,不行吧,download()这个是哪里的函数,我是在WEB上的编程阿
      

  3.   


    Response.Clear();
                
    FileStream fs = File.Open(Server.MapPath(filePath), FileMode.Open);
    byte[] bs = new byte[fs.Length];
    fs.Read(bs,0,bs.Length-1);
    System.Text.UTF8Encoding uen = new System.Text.UTF8Encoding();
    char[] cs = uen.GetChars(bs);Response.Write(cs, 0, cs.Length);
      

  4.   

    当超级连接目标为浏览器不能识别的文件格式时,就自动生成下载连接
    所以:
    <a href=xxx.zip></a>
    就可以了