http://hi.baidu.com/xiaohuizuan/blog/item/95355933bc3ab7fe14cecb3f.html

 

前几天做了一个网站,里面用到了迅雷下载功能,在网上找了一下代码整理了一下,现在拿出来了大家共享吧

首先在.aspx页面配置信息

<script runat=server> public string ThunderEncode(string code) { code="AA"+code+"ZZ"; string encode = ""; byte[] bytes = Encoding.GetEncoding(54936).GetBytes(code); try { encode = Convert.ToBase64String(bytes); } catch { encode = code; } return "thunder://"+encode; } </script>

<script src="http://pstatic.xunlei.com/js/webThunderDetect.js"></script> <a href="#" thunderHref="<%=ThunderEncode("http://请改成你需要的链接.rar")%>" thunderPid="57029" thunderType="" thunderResTitle="" onClick="return OnDownloadClick_Simple(this,2,4)" oncontextmenu="ThunderNetwork_SetHref(this)" >迅雷专用高速下载</a> <br />         <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1" />

 

然后再.cs文件里面填入

protected void Button1_Click1(object sender, EventArgs e)     {         Response.ContentType = "application/x-zip-compressed";         Response.AddHeader("Content-Disposition", "attachment;filename=z.zip");         string filename = Server.MapPath("下载文件路径");         Response.TransmitFile(filename);

    }