国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net(c#)下讀取word文檔的方法小結

2020-01-18 00:40:56
字體:
來源:轉載
供稿:網友
第一種方法:
復制代碼 代碼如下:

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();
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 库车县| 信丰县| 黑山县| 凤庆县| 广平县| 张家界市| 青铜峡市| 恩平市| 衡山县| 镇原县| 离岛区| 扎鲁特旗| 珠海市| 色达县| 阿合奇县| 巴东县| 新干县| 新竹市| 汉寿县| 安陆市| 株洲县| 衡阳市| 荥经县| 蓬安县| 九台市| 清涧县| 上思县| 庆阳市| 丹寨县| 新竹县| 遵义市| 华阴市| 顺平县| 凭祥市| 安义县| 乐山市| 华蓥市| 盘山县| 教育| 封开县| 伽师县|