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

首頁 > 編程 > .NET > 正文

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

2024-07-10 12:41:52
字體:
來源:轉載
供稿:網友
第一種方法:
代碼如下:
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();
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沙洋县| 四平市| 横山县| 富锦市| 新安县| 文化| 阜阳市| 镇雄县| 潢川县| 石棉县| 南雄市| 通许县| 高密市| 铜陵市| 汾阳市| 黎平县| 娄底市| 濮阳县| 彰化市| 北安市| 茌平县| 前郭尔| 靖宇县| 甘肃省| 阿鲁科尔沁旗| 南江县| 伊春市| 罗山县| 湘潭市| 平顶山市| 汨罗市| 新巴尔虎左旗| 定南县| 依安县| 疏附县| 固始县| 武夷山市| 凉山| 临漳县| 卓资县| 抚松县|