zoukankan      html  css  js  c++  java
  • asp.net 读取word 文档的方法新随笔 1. net 学习线路图,csdn真给力啊!

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

  • 相关阅读:
    存储过程示例
    对话:关于委托的进一步讨论(转)
    Oracle SQLServer 的随机数问题 .(转)
    AJAX控件之AutoComplete
    穷人与富人的区别
    喜欢(转)
    用sql求得每行行号
    ajax 注册
    如何快速生成100万不重复的8位编号 (转)
    存儲過程的基本語句
  • 原文地址:https://www.cnblogs.com/y0umer/p/3839092.html
Copyright © 2011-2022 走看看