国产探花免费观看_亚洲丰满少妇自慰呻吟_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://m.survivalescaperooms.com/skylaugh/archive/2006/12/18/596074.html


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宜春市| 兖州市| 张北县| 焦作市| 嘉鱼县| 芷江| 麻江县| 阜阳市| 云霄县| 噶尔县| 石泉县| 孟村| 武平县| 类乌齐县| 额敏县| 东乌| 邓州市| 衢州市| 鸡东县| 高青县| 获嘉县| 兰坪| 上思县| 金湖县| 巴青县| 亳州市| 北流市| 民和| 博客| 多伦县| 毕节市| 黄陵县| 崇信县| 东乡县| 唐河县| 金秀| 保山市| 镇远县| 伊金霍洛旗| 革吉县| 玉环县|