blueskyc's blog
永不放弃

 
        FileStream objStream = null;
        byte[] objBytes = null;
        string strFileName = string.Empty;
        string strMessage = string.Empty;  

    string strDownloadFileFullPath = Server.UrlDecode(this.hdnDownloadPath.Value);

 

       objStream = File.Open(strDownloadFileFullPath, FileMode.Open);
            objBytes = new byte[(int)objStream.Length];
            objStream.Read(objBytes, 0, objBytes.Length);

            // ダウンロードファイル情報を取得する
            FileInfo objInfo = new FileInfo(strDownloadFileFullPath);
            // ファイル名称を取得する
            strFileName = Server.UrlEncode(objInfo.Name);

            // ダウンロードを実行する
            Response.ContentType = "application/ms-excel";
            Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);
            Response.BinaryWrite(objBytes);
            Response.Flush();

posted on 2009-09-29 16:41  Cherry Chen  阅读(307)  评论(0编辑  收藏  举报