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

首頁 > 學院 > 開發設計 > 正文

下載文件出現提示框或者直接顯示在瀏覽器中

2019-11-18 16:48:05
字體:
來源:轉載
供稿:網友

有個朋友問我下載彈出提示框的寫法,具體如下:

出現提示框

string strFile="F://a.doc";//路徑根據實際情況而定
if(!System.IO.File.Exists(strFile))
   {
    Response.Write("<script language='javascript'>alert('對不起,文件不存在!');</script>");
    return;
   }
   Response.Clear();
   Response.ClearHeaders();
   Response.Charset = "GB2312";
   Response.ContentEncoding =System.Text.Encoding.UTF8;
   Response.ContentType = "application/octet-stream";
   FileInfo fi=new FileInfo(strFile);
   Response.AddHeader("Content-Disposition","attachment;  filename="  +  HttpUtility.UrlEncode(fi.Name)) ;
   Response.AddHeader("Content-Length",fi.Length.ToString());
   byte[] tmpbyte=new byte[1024*8];
   FileStream fs=fi.OpenRead();
   int count;
   while((count=fs.Read(tmpbyte,0,tmpbyte.Length))>0)
   {
    Response.BinaryWrite(tmpbyte);
    Response.Flush();
   }
   fs.Close();  
   Response.End();

直接在瀏覽器中打開
   string strFile="F://a.doc";//路徑根據實際情況而定
   Response.Clear();
   Response.ClearHeaders();
   Response.Charset = "GB2312";
   Response.ContentEncoding =System.Text.Encoding.UTF8;
   Response.ContentType = "application/msWord";
   Response.WriteFile(strFile);

http://www.survivalescaperooms.com/skylaugh/archive/2006/12/18/596074.html


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 米易县| 赤峰市| 濮阳市| 淄博市| 隆安县| 庐江县| 秭归县| 抚远县| 施秉县| 新民市| 都江堰市| 南宫市| 莱州市| 蒙山县| 康定县| 广水市| 洞口县| 乌拉特后旗| 天气| 珠海市| 太仆寺旗| 克拉玛依市| 万载县| 综艺| 新沂市| 富顺县| 锦州市| 宜都市| 郁南县| 广宁县| 上犹县| 冷水江市| 班戈县| 云南省| 温泉县| 谢通门县| 棋牌| 咸阳市| 武山县| 菏泽市| 防城港市|