asp.net 读取word 文档的方法新随笔 1. net 学习线路图,csdn真给力啊!

简介: 第一种方法:    Response.ClearContent();   Response.ClearHeaders();   Response.ContentType = "Application/msword";   string s=Server.

第一种方法:
   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(); 

http://www.cnblogs.com/suneryong/archive/2007/06/05/772115.html

目录
相关文章
|
开发框架 前端开发 JavaScript
盘点72个ASP.NET Core源码Net爱好者不容错过
盘点72个ASP.NET Core源码Net爱好者不容错过
663 0
|
开发框架 .NET
ASP.NET Core NET7 增加session的方法
ASP.NET Core NET7 增加session的方法
295 0
|
11月前
|
人工智能 API 数据库
Semantic Kernel .NET 架构学习指南
本指南系统解析微软Semantic Kernel .NET架构,涵盖核心组件、设计模式与源码结构,结合实战路径与调试技巧,助你从入门到贡献开源,掌握AI编排开发全栈技能。
1228 2
|
Java 物联网 C#
C#/.NET/.NET Core学习路线集合,学习不迷路!
C#/.NET/.NET Core学习路线集合,学习不迷路!
852 0
|
开发框架 .NET 中间件
C#/.NET快速上手学习资料集(让现在的自己不再迷茫)
C#/.NET快速上手学习资料集(让现在的自己不再迷茫)
667 8
|
Linux C# Windows
.NET使用MiniWord高效生成Word文件
.NET使用MiniWord高效生成Word文件
653 12
学习计算机组成原理(王道考研)------第十一天https://zhengyz.blog.csdn.net/article/details/121706379?spm=1001.2014.3001.5502
这篇文章是关于计算机组成原理的王道考研学习笔记,主要介绍了半导体存储器RAM和ROM的相关知识。
学习计算机组成原理(王道考研)------第十一天https://zhengyz.blog.csdn.net/article/details/121706379?spm=1001.2014.3001.5502
|
开发框架 JSON .NET
ASP.NET Core 标识(Identity)框架系列(三):在 ASP.NET Core Web API 项目中使用标识(Identity)框架进行身份验证
ASP.NET Core 标识(Identity)框架系列(三):在 ASP.NET Core Web API 项目中使用标识(Identity)框架进行身份验证
490 1
|
机器学习/深度学习 PyTorch 算法框架/工具
【文献学习】Phase-Aware Speech Enhancement with Deep Complex U-Net
文章介绍了Deep Complex U-Net模型,用于复数值的语音增强,提出了新的极坐标掩码方法和wSDR损失函数,并通过多种评估指标验证了其性能。
513 1