在asp.net中如何实现下载功能,要能用下载工具下载!请哪位高手把代码发一下,详细点啊!谢谢!

来源:百度知道 编辑:UC知道 时间:2024/05/22 13:01:16
我是新手,麻烦说清楚点!

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class _Default : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{

}

//下载
protected void Button1_Click(object sender, EventArgs e)
{
string path = Server.MapPath("video") + "\\XX.wmv";
//初始化 FileInfo 类的实例,它作为文件路径的包装
FileInfo fi = new FileInfo(path);
Response.Write(path);
// 判断文件是否存在
if (fi.Exists)
{
// 将文件保存到本机上
Response.Clear();
Response.AddHeader("Content-Disposition", "a