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

首頁 > 編程 > .NET > 正文

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

2024-07-10 13:25:08
字體:
來源:轉載
供稿:網友
第一種方法:

復制代碼 代碼如下:


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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柞水县| 惠东县| 会昌县| 双牌县| 扎兰屯市| 揭西县| 古丈县| 叶城县| 甘孜| 尤溪县| 岑溪市| 神农架林区| 浮山县| 鹤庆县| 大丰市| 平潭县| 新巴尔虎左旗| 深水埗区| 浪卡子县| 石渠县| 鄂尔多斯市| 平昌县| 土默特左旗| 安庆市| 博罗县| 自治县| 额济纳旗| 德阳市| 庆云县| 赣榆县| 梅河口市| 德州市| 松原市| 西乌| 汉中市| 湘阴县| 墨竹工卡县| 天祝| 张北县| 开原市| 抚顺县|