基本信息
源码名称:C#将word文件存入数据库与读取(Web版)
源码大小:1.21M
文件格式:.rar
开发语言:C#
更新时间:2021-11-06
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 10 元×
微信扫码支付:10 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
最新版本,更新了老版本只能在本地导出WORD文档,新版本可以用于网站
最新版本,更新了老版本只能在本地导出WORD文档,新版本可以用于网站
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; 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.Xml.Linq; using System.IO; using testModels; using testBLL; namespace test { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { Stream fileStream = fulPath.PostedFile.InputStream; //获取上传文件字节的大小 int length = fulPath.PostedFile.ContentLength; byte[] wordData = new byte[length]; //从流中读取字节并写入wordData int n = fileStream.Read(wordData, 0, length); //下面把wordData保存进数据库 Words wd = new Words(); wd.name = TextBox1.Text.Trim(); wd.wordData = wordData; WordsManage.AddWords(wd); } /// <summary> /// 根据TextBox2传入的文件名调出WORD文档 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button2_Click(object sender, EventArgs e) { Context.Response.Buffer = true; Context.Response.Clear(); Context.Response.ContentType = "application/msword"; Context.Response.AddHeader("Content-Disposition", "attachment;filename=" HttpUtility.UrlEncode(TextBox2.Text.Trim() ".doc", System.Text.Encoding.UTF8)); Context.Response.BinaryWrite(WordsManage.GetBtBybh(TextBox2.Text.Trim())); Context.Response.Flush(); Context.Response.End(); } } }