首页 > 学院 > 开发设计 > 正文

文件下载

2019-11-06 07:14:22
字体:
来源:转载
供稿:网友

使用超链接下载

    <form id="form1" runat="server">        <div>            <a href="UploadPic/uwo9-logo.rar">请点击此处下载文件</a>        </div>    </form>使用Respobse对象TransmitFile方法

    <form id="form1" runat="server">        <div>            <asp:Button ID="btnDown" runat="server" Text="下载" OnClick="btnDown_Click" />        </div>    </form>
        PRotected void btnDown_Click(object sender, EventArgs e)        {            Response.ContentType = "application/x-zip-compressed";            Response.AddHeader("Content-Disposition", "attachment;filename=uwo9-logo.zip");            string filename = Server.MapPath("UploadPic/uwo9-logo.zip");            Response.TransmitFile(filename);        }


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表