将服务器上的一个.doc文档另存为到客户端

protected void applyLetter_Click(object sender, EventArgs e)
    {
        string strFileName = Server.MapPath("../InvitationLetterApplicationFormForVisa.doc");
        FileInfo DownloadFile = new FileInfo(strFileName);
        Response.Clear();
        Response.ClearHeaders();
        Response.Buffer = false;
        Response.ContentType = "application/octet-stream";
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(strFileName, System.Text.Encoding.UTF8));
        Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
        Response.WriteFile(DownloadFile.FullName);
        Response.Flush();
        Response.End();
        string strWhere = "UserName='" + Session["UserNameEN"].ToString() + "'";
    }
posted @ 2008-11-04 11:22  Max Woods  阅读(314)  评论(0编辑  收藏  举报