当前位置:编程学习 > C#/ASP.NET >>

新手、前辈们、能提供个下载页面吗?

新手、前辈们、能提供个下载页面吗?最好是软件下载的那种[img=http://hi.csdn.net/space-8683033-do-album-picid-759611-goto-down.html][/img] --------------------编程问答--------------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;

public partial class Annex_AnnexDownload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //文件名称与路径
        string FileName = Server.UrlDecode(Request.QueryString["fileName"].ToString());
        string FilePath = Server.UrlDecode(Request.QueryString["Action"].ToString());

        this.FileDownload(FileName, FilePath);
    }

    /// <summary>
    /// 下载文件
    /// </summary>
    /// <param name="FileName"></param>
    public void FileDownload(string FileName, string FilePath)
    {
        String FullFileName = System.Web.HttpContext.Current.Server.MapPath(FilePath);
        FileInfo DownloadFile = new FileInfo(FullFileName);
        System.Web.HttpContext.Current.Response.Clear();
        System.Web.HttpContext.Current.Response.ClearHeaders();
        System.Web.HttpContext.Current.Response.Buffer = false;
        System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
        System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8));
        System.Web.HttpContext.Current.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
        System.Web.HttpContext.Current.Response.WriteFile(DownloadFile.FullName);
        System.Web.HttpContext.Current.Response.Flush();
        System.Web.HttpContext.Current.Response.End();
    }
}
--------------------编程问答-------------------- 上面的试下.
不太明白楼猪的意思.
补充:.NET技术 ,  非技术区
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,