我现在是把文件在服务器上保存着不是在虚拟目录里面保存,这是路径ftp://220.95.232.41/BVO Global Edition.exe 
现在要做一个下载,让别人把我这个文件可以下载下来怎么做? 小弟谢谢了

解决方案 »

  1.   

    WebClient client = new WebClient();
                client.DownloadFile("地址", "本地存放位置");
    这样吗?
      

  2.   

    webclient
    ftpwebrequest
    http://topic.csdn.net/u/20100101/11/31f537a5-e615-4588-aac8-c82acf1241bb.html
      

  3.   

    文件下载方法,试试看。  /// <summary>
            /// 下载服务器文件至客户端
            /// </summary>
            /// <param name="url">被下载的文件地址,绝对路径</param>
            /// <param name="dir">另存放的目录</param>
            public void DownloadUrlFile(string url, string dir)
            {
                WebClient client = new WebClient();
                string fileName = Path.GetFileName(url);  //被下载的文件名
                string path = dir + fileName;   //另存为的绝对路径+文件名            try
                {
                    if (!System.IO.Directory.Exists(dir))
                    {
                        System.IO.Directory.CreateDirectory(dir);
                    }
                    if (!System.IO.File.Exists(path))
                    {
                        client.DownloadFile(url, path);
                    }
                }
                catch (Exception)
                {
                    // ShowError("文件下载失败!");
                }
            }
      

  4.   

    直接做个到这个文件的ftp地址的链接不行吗??
      

  5.   


    Response.ContentType = "application/octet-stream";
    Response.AddHeader("Content-Disposition", "attachment;  filename=" + HttpUtility.UrlEncode([默认下载文件名], System.Text.Encoding.UTF8));
    Response.BinaryWrite([char[] buff]);//buff:文件内容
    Response.Flush();
    Response.End();
      

  6.   

    你可以把ftp账号和密码加在ftp路径中,当然如果怕别人知道的话那就另当别论了
      

  7.   

    谢谢各位!我下载的代码都正确着 但是我是用 <a href="downnum.aspx" target="_blank"><img src="images/download_btn_09.jpg" height="28" width="100" style="border:0"></a>  当点击的时候发送到downnum.aspx这个页面 downnum.aspx这个页面有个onload事件
    <body onload=" load(); ">
        <form id="form1" runat="server">
        <script type="text/javascript" language="javascript" >
            
            function load() {
            
                 window.location.href = "ftp://220.95.232.41/BVO Global Edition.exe";
                 
            }
        </script>
    ftp://220.95.232.41/BVO Global Edition.exe 这是放在服务器上的一个文件 有时候可以下载但是有时候就不能下载 很郁闷!
      

  8.   

    那是FTP服务器的问题,不是你的网站的问题,你跳转到ftp那个地址后就和你网站没关系了。不过我看你的文件名,里面有空格,应该考虑用javascript的escape函数把ftp下载地址编码一下。
      

  9.   

    用FTP上传文件的话是要用账号和密码,而且在服务器端还要安装一个ftp服务器,下载倒是不用安装