各位兄弟,你们好?
我们公司开发的是B/S架构,现在我要求把服务器的指定文件夹中的文件下载到客户端,怎样做?谢谢!

解决方案 »

  1.   


    /// <summary>
    /// 把服务器上的文件下载到客户端,在客户端出现另存为的对话框。
    /// </summary>
    /// <param name="response">response对象</param>
    /// <param name="strAbsoluteFullPath">服务器上的文件,绝对路径,比如"C:\intput\wwwroot\test\测试.doc"</param>
    /// <param name="strUrlEncodeClientFileName">客户端另存为时,默认的文件名,比如"测试.doc",经url编码</param>
    public static void ClientDownload(System.Web.HttpResponse  response, string strAbsoluteFullPath, string strUrlEncodeClientFileName)
    {
    System.IO.FileInfo File = new System.IO.FileInfo(strAbsoluteFullPath);
    response.Clear();
    response.ClearHeaders();
    response.Buffer = true;
    response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
    response.AddHeader("Content-Disposition",  "attachment;filename=" + strUrlEncodeClientFileName);
    response.AddHeader("Content-Length",  File.Length.ToString())  ;
    response.ContentType = "application/octet-stream"  ;
    response.WriteFile(File.FullName)  ;
    response.Flush();
    response.End()  ;
    }
      

  2.   

    用vb.net编的语句是什么啊?
    哪位大虾知道?请不吝赐教
    小弟正急着用  是在vb.net下的asp.net  需要实现的是软件下载功能(就是点击一个按钮,然后实现链接软件下载)
    万分感谢!