- 相關推薦
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文檔的方法】相關文章:
PHP生成Word文檔的方法06-28
恢復受損Word文檔的9種方法06-21
幾種找回Word文檔損壞了的數據的方法08-31
Word文檔內部的創建超級鏈接的方法06-02
C語言的reduce方法應用10-22
C語言的冒泡排序方法08-22
怎么Word文檔的內存變小09-21
word文檔打印的小技巧07-27
使用Word文檔的小技巧10-13