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();
    }

解决方案 »

  1.   

    lovehongyun所说的这种方法下载时只有对话框不会打开新页面的
      

  2.   

    lovehongyun
    所说的方法即可
    不知道楼主的打开窗口
    是不是 点了下载 关闭当前窗口呢?
    添加
    Response.Write("<script>window.opener=null;self.close();</script>");
      

  3.   

    在空白页 <html>
      <head>
      <object id=closes type="application/x-oleobject"
      classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
      <param name="Command" value="Close">
      </object>
      </head>
      <body onload="window.setTimeout('closes.Click()',10000)">
      这个窗口会在10秒过后自动关闭,而且不会出现提示.
      </body>
      </html> 仅做参考
      

  4.   

    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();
    }这个应该可以的
      

  5.   

    CH_MARS(上帝的右手)
    你确定你的这个关闭好用吗?我试验了,没灵
      

  6.   

    最关键的是要能实现 比如 服务器的ip : 192.168.0.1 我再192.168。0.2 的机器上怎么能下载到  http://192.168.0.1/file/music1.wav 这个文件