C语言

C语言读取word文档的方法

时间:2025-05-21 03:37:36 C语言 我要投稿
  • 相关推荐

C语言读取word文档的方法

  第一种方法:

  复制代码 代码如下:

  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();

【C语言读取word文档的方法】相关文章:

C语言中读取时间日期的基本方法09-11

word文档分栏的方法08-12

合并多个word文档的方法09-16

快速打开Word文档的方法09-21

word文档加密方法分享10-03

PHP生成Word文档的方法06-28

word文档删除分节符的方法09-12

c语言读取顺序文件并处理10-11

Word文档出现乱码的解决方法08-24