asp.net c#读取word 文档的方法
2012-08-06 15:10
736 查看
第一种方法:
第二种方法:
第三种方法:
Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "Application/msword"; string s=Server.MapPath("C#语言参考.doc"); Response.WriteFile("C#语言参考.doc"); Response.Write(s); Response.Flush(); Response.Close();
第二种方法:
Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "Application/msword"; string strFilePath=""; strFilePath =Server.MapPath("C#语言参考.doc"); FileStream fs = new FileStream(strFilePath,FileMode.OpenOrCreate,FileAccess.Read); Response.WriteFile(strFilePath,0,fs.Length); fs.Close();
第三种方法:
string path=Server.MapPath("C#语言参考.doc"); FileInfo file=new FileInfo(path); FileStream myfileStream=new FileStream(path,FileMode.Open,FileAccess.Read); byte[] filedata=new Byte[file.Length]; myfileStream.Read(filedata,0,(int)(file.Length)); myfileStream.Close(); Response.Clear(); Response.ContentType="application/msword"; Response.AddHeader("Content-Disposition","attachment;filename=文件名.doc"); Response.Flush(); Response.BinaryWrite(filedata); Response.End();
相关文章推荐
- asp.net(C#)读取word 文档的方法
- asp.net(c#)下读取word文档的方法小结
- asp.net(c#)下读取word文档的方法小结
- ASP.NET读取Word文档转换为PDF文件的方法
- asp.net 读取word 文档的方法
- asp.net 读取word 文档的方法
- asp.net 读取word 文档的方法
- asp.net 读取word 文档的方法
- asp.net 读取word 文档的方法新随笔 1. net 学习线路图,csdn真给力啊!
- asp.net 读取word 文档的方法新随笔 1. net 学习线路图,csdn真给力啊!
- ASP.NET C#如何读取word,写入word,复制内容到另一个word文档,批量修改文件名
- [转]ASP.NET C#如何读取word,写入word,复制内容到另一个word文档,批量修改文件名
- ASP.NET读取Word文档转换为PDF文件的方法
- asp.net读取word文档
- asp.net下用Aspose.Words for .NET动态生成word文档中的图片或水印的方法(转)
- C# asp.net 操作Word的前提配置和简单的方法
- ASP.NET(C#) 读取EXCEL另加解决日期问题的方法分享
- asp.net下用Aspose.Words for .NET动态生成word文档中的图片或水印的方法
- asp.net下用Aspose.Words for .NET动态生成word文档中的数据表格的方法(转)
- asp.net下用Aspose.Words for .NET动态生成word文档中的图片或水印的方法