您的位置:首页 > 编程语言 > C#

C#下载代码,防迅雷

2009-03-15 13:00 239 查看
 protected void btn_Download_Click(object sender, EventArgs e)
    {
        string strFileUploadPath = "Files/";
        //从列表框控件中读取选择的文件名
        string strFileName = lb_FileList.SelectedValue;

//组合成物理路径
        string strFilePhysicalPath = Server.MapPath("~/" + strFileUploadPath + strFileName);
        Response.Clear();
        Response.ContentType = "application/octet-stream";
        Response.AddHeader("Content-Disposition", "attachment;FileName=" + HttpUtility.UrlEncode(strFileName, System.Text.Encoding.UTF8));
        Response.WriteFile(strFilePhysicalPath);
        Response.End();
    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c# string download object