像网页上那些下载的:比如说本地下载,你点击链接的话,就会直接下载
还有就是电信下载了,我感觉这些就是超链接,不知道用ASP.NET应该怎么实现呢?请大家帮帮我,谢谢
我不知道这是怎么个原理,如果有代码可以借我研究一下,谢谢,呵呵

解决方案 »

  1.   

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

  2.   

    连接的URL就写你的文件存放路径 相对路径。 注意打包文件,比如TXT BMP这种浏览器直接显示而不是下载至于你说的点击直接打开迅雷 我估计是一种 协议, 也是写在URL里的。 网上搜下吧
      

  3.   

     #region 下载服务器上的文件
            /// <summary>
            /// 下载服务器上的文件
            /// </summary>
            /// <param name="PageResponse">程序中可以设置参数:HttpResponse ht=Page.Response;</param>
            /// <param name="serverPath">服务器上的文件路径</param>
            public void DownloadFile(HttpResponse response, string serverPath)
            {
                FileStream fs = null;
                try
                {
                    fs = File.OpenRead(serverPath);
                    byte[] buffer = new byte[1024];
                    long count = 1024;
                    response.Buffer = true;
                    response.AddHeader("Connection", "Keep-Alive");
                    response.ContentType = "application/octet-stream";
                    response.AddHeader("Content-Disposition", "attachment;filename=" + Path.GetFileName(serverPath));//下载时要保存的默认文件名
                    response.AddHeader("Content-Length", fs.Length.ToString());
                    while (count == 1024)
                    {
                        count = fs.Read(buffer, 0, 1024);
                        response.BinaryWrite(buffer);
                    }
                    
                }
                catch
                {
                }
                finally
                {
                    fs.Close();
                }
            }
            #endregion指定路径就好了
      

  4.   

    asp.net下载文件的常用方法
    http://blog.sina.com.cn/s/blog_5dfb7f4d0100c3nh.html
      

  5.   

    .NET(C#)技术交流 35032539 
    .NET(C#)技术交流 35032539 
    .NET(C#)技术交流 35032539 
      

  6.   

    private void StartReceive()
    {

    IPEndPoint ipep=new IPEndPoint(IPAddress.Parse(this.textBox1.Text),int.Parse(this.textBox5.Text));

    Socket client=new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);

    client.Connect(ipep);

    string SendFileName=System.Text.Encoding.Unicode.GetString(CommonModule.EzoneModule.ReceiveVarData(client));
    this.textBox2.Text=SendFileName;

    this.textBox3.Text=System.Text.Encoding.Unicode.GetString(CommonModule.EzoneModule.ReceiveVarData(client));

    this.textBox8.Text=System.Text.Encoding.Unicode.GetString(CommonModule.EzoneModule.ReceiveVarData(client));
    this.progressBar1.Maximum=int.Parse(this.textBox8.Text);

    this.textBox9.Text=System.Text.Encoding.Unicode.GetString(CommonModule.EzoneModule.ReceiveVarData(client));

    FileStream MyFileStream=new FileStream(SendFileName,FileMode.Create,FileAccess.Write);

    int SendedCount=0;
    while(true)
    {
    byte[] data=CommonModule.EzoneModule.ReceiveVarData(client);
    if(data.Length==0)
    {
    break;
    }
    else
    {
    SendedCount++;

    MyFileStream.Write(data,0,data.Length);

    this.textBox10.Text=SendedCount.ToString();

    this.progressBar1.PerformStep();
    }
    }
    this.progressBar1.Value=this.progressBar1.Maximum;
    //关闭文件流
    MyFileStream.Close();
    //关闭套接字
    client.Close();
    this.button1.Enabled=true;
    MessageBox.Show("文件接收完毕!");
    }
      

  7.   

    CSDN 查一下webclient 这个是最简单的
      

  8.   

    以前就用的超链接直接在href里写路径就可以了,今天弄了好久也不行....郁闷.....