/// <summary> /// 下载文件方法 /// </summary> /// <param name="data">二进制流</param> /// <param name="fileName">文件名</param> /// <param name="fileType">后缀后</param> protected virtual void OutputStream(byte[] data, string fileName, string fileType) { byte[] attachment = SharpZipLib.DeCompress(data); FineOffice.Web.FileTypeHelper typeHelper = new FineOffice.Web.FileTypeHelper(); Response.Clear(); Response.Buffer = true; Response.Charset = "utf-8"; Response.AddHeader("Content-Disposition", "attachment; filename=" + typeHelper.ToHexString(fileName + "." + fileType)); Response.AddHeader("Content-Length", attachment.Length.ToString()); Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); Response.OutputStream.Write(attachment, 0, attachment.Length); Response.Flush(); }
protected void btnDownAttachment_Click(object sender, EventArgs e) { int id = int.Parse(attachmentGrid.DataKeys[attachmentGrid.SelectedRowIndex][0].ToString()); FineOffice.Modules.OA_Attachment model = attBll.GetModel(d => d.ID == id); byte[] attachmentData = SharpZipLib.DeCompress(model.AttachmentData); FineOffice.Web.FileTypeHelper typeHelper = new FineOffice.Web.FileTypeHelper(); Response.Clear(); Response.Buffer = true; Response.Charset = "utf-8"; Response.AddHeader("Content-Disposition", "attachment; filename=" + typeHelper.ToHexString(model.FileName + "." + model.XType)); Response.AddHeader("Content-Length", attachmentData.Length.ToString()); Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); Response.OutputStream.Write(attachmentData, 0, attachmentData.Length); Response.Flush(); }
protected void btnDownForm_Click(object sender, EventArgs e) { int id = int.Parse(formGrid.DataKeys[formGrid.SelectedRowIndex][0].ToString()); FineOffice.Modules.OA_FlowRunData model = runDataBll.GetModel(d => d.ID == id); byte[] formData = SharpZipLib.DeCompress(model.FormData); this.Response.Clear(); this.Response.Buffer = true; this.Response.Charset = "utf-8"; this.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(model.Title + "." + model.XType)); this.Response.AddHeader("Content-Length", formData.Length.ToString()); this.Response.ContentType = "application/msword"; this.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); this.Response.OutputStream.Write(formData, 0, formData.Length); this.Response.Flush(); }