asp.net 写入word 浏览器提示保存
来源:互联网 发布:c语言接口与实现 pdf 编辑:程序博客网 时间:2024/05/23 10:56
string path = Server.MapPath("测试.doc");//服务器上面先放置一个word文件
FileInfo file = new FileInfo(path);
FileStream myfileStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);//以读写方式打开word文件
//byte[] filedata = new Byte[file.Length];
string info="wwwwwwww";
byte[] filedata = System.Text.Encoding.Default.GetBytes(info);
myfileStream.Write(filedata, 0, filedata.Length);
//myfileStream.Read(filedata, 0, (int)(file.Length));
myfileStream.Close();
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("1.doc", Encoding.UTF8));
Response.ContentType = "application/ms-word";
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Flush();
Response.BinaryWrite(filedata);
FileInfo file = new FileInfo(path);
FileStream myfileStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);//以读写方式打开word文件
//byte[] filedata = new Byte[file.Length];
string info="wwwwwwww";
byte[] filedata = System.Text.Encoding.Default.GetBytes(info);
myfileStream.Write(filedata, 0, filedata.Length);
//myfileStream.Read(filedata, 0, (int)(file.Length));
myfileStream.Close();
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("1.doc", Encoding.UTF8));
Response.ContentType = "application/ms-word";
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Flush();
Response.BinaryWrite(filedata);
Response.End();
需要使用UTF8部分,不使用结果可能会有出入
0 0
- asp.net 写入word 浏览器提示保存
- asp.net 写入Alert为什么不提示?
- .ASP.NET页面跳转提示保存(原创)
- asp.net将word转换为html保存
- asp.net将word转换为html保存
- asp.net将word转换为html保存
- asp.net将word转换为html保存
- asp.net 写入word (Microsoft.Office.Interop.Word)经验记录(看不明白问我)
- ASP.NET C#如何读取word,写入word,复制内容到另一个word文档,批量修改文件名
- C#中写入与保存Word文档
- ASP读取文件 ASP写入/保存文件
- ASP读取文件 ASP写入/保存文件
- 如何使用 ASP.NET 和 Visual C# .NET 向浏览器写入二进制文件
- asp.net DataSet数据写入Excel保存自定义名称到默认文件夹内
- asp.net操作word
- asp.net Word 操作
- asp.net 生成word
- ASP.NET 读取Word
- 利用ArcMap的2个功能来帮助学习ArcPy
- LNK2005与头文件中的全局常量
- 云平台应用需求分析
- struts2.xml中使用chain和redirectAction这两个类型结果(type-result)时,报检查错误(validation)
- DirectX 10 教程5:纹理
- asp.net 写入word 浏览器提示保存
- 关于java.lang.IllegalStateException: getOutputStream() has already been called for this response求解
- 最小生成树(kruskal) hdu 1233
- 万物负阴而抱阳
- 数据库的连接
- 排序算法之归并排序
- Java反射机制Class类的用法详解
- 详解Objective-C中委托和协议
- 枚举类enum