文件下载

 /// <summary>
    /// 文件下载
    /// </summary>
    /// <param name="strFullFilepath"></param>
    protected void DownLoadAttachment(string strFullFilepath)
    {
        #region
        if (strFullFilepath != "")
        {
            string path = strFullFilepath;
            System.IO.FileInfo file = new System.IO.FileInfo(path);
            if (file.Exists)
            {
                Response.Clear();
                Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
                Response.AddHeader("Content-Length", file.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.Filter.Close();
                Response.WriteFile(file.FullName);
                Response.End();
            }
            else
            {
                base.Alert("资源不存在!");
            }
        }
        #endregion
    }
posted @ 2012-09-28 10:30  只求清淡如水  阅读(116)  评论(0编辑  收藏  举报