当前位置: 首页 > news >正文

建设b2b网站要求seo运营是什么

建设b2b网站要求,seo运营是什么,wordpress更改端口,中山网站建设文化流程原文地址为: C#实现文件下载 1,Http 协议中有专门的指令来告知浏览器, 本次响应的是一个需要下载的文件. 格式如下:Content-Disposition: attachment;filenamefilename.ext以上指令即标记此次响应流是附件,且附件文件名为 filename.ext注意:…
原文地址为: C#实现文件下载

1,Http 协议中有专门的指令来告知浏览器, 本次响应的是一个需要下载的文件. 格式如下:
Content-Disposition: attachment;filename=filename.ext
以上指令即标记此次响应流是附件,且附件文件名为 filename.ext
注意:
(1): 中文文件名需要进行URLEncode编码, 否则在IE 6 下会提示是”无法识别的文件”.

但经实际测试,在Chrome下不进行URLEncode编码, 也能正常显示.

(2): 文件名不能有空格, 否则也会被认为是”无法识别的文件”.

(3): [ASP.Net中] 向响应流中添加该指令必须使用 response.AddHeader() 函数; 使用

response.Header.Add() 则会报错.

下面是一个实现下载文件功能的函数:

       /// <summary>/// 使用微软的TransmitFile下载文件/// </summary>/// <param name="filePath">服务器相对路径</param>public void TransmitFile(string filePath){try{filePath = Server.MapPath(filePath);if (File.Exists(filePath)){FileInfo info = new FileInfo(filePath);long fileSize = info.Length;HttpContext.Current.Response.Clear();                    //指定Http Mime格式为压缩包HttpContext.Current.Response.ContentType = "application/x-zip-compressed";// Http 协议中有专门的指令来告知浏览器, 本次响应的是一个需要下载的文件. 格式如下:// Content-Disposition: attachment;filename=filename.txtHttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(info.FullName));//不指明Content-Length用Flush的话不会显示下载进度   HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());HttpContext.Current.Response.TransmitFile(filePath, 0, fileSize);HttpContext.Current.Response.Flush();}}catch{ }finally{HttpContext.Current.Response.Close();}}

2 下面是使用WriteFile实现下载

        /// <summary>/// 使用WriteFile下载文件  /// </summary>/// <param name="filePath">相对路径</param>public void WriteFile(string filePath){try{filePath = Server.MapPath(filePath);if (File.Exists(filePath)){FileInfo info = new FileInfo(filePath);long fileSize = info.Length;HttpContext.Current.Response.Clear();HttpContext.Current.Response.ContentType = "application/octet-stream";HttpContext.Current.Response.AddHeader("Content-Disposition", "attachement;filename=" + Server.UrlEncode(info.FullName));//指定文件大小   HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());HttpContext.Current.Response.WriteFile(filePath, 0, fileSize);HttpContext.Current.Response.Flush();}}catch{ }finally{HttpContext.Current.Response.Close();}}

3,下面是分块实现下载:

        /// <summary>/// 使用OutputStream.Write分块下载文件  /// </summary>/// <param name="filePath"></param>public void WriteFileBlock(string filePath){filePath = Server.MapPath(filePath);if (!File.Exists(filePath)){return;}FileInfo info = new FileInfo(filePath);//指定块大小   long chunkSize = 4096;//建立一个4K的缓冲区   byte[] buffer = new byte[chunkSize];//剩余的字节数   long dataToRead = 0;FileStream stream = null;try{//打开文件   stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);dataToRead = stream.Length;//添加Http头   HttpContext.Current.Response.ContentType = "application/octet-stream";HttpContext.Current.Response.AddHeader("Content-Disposition", "attachement;filename=" + Server.UrlEncode(info.FullName));HttpContext.Current.Response.AddHeader("Content-Length", dataToRead.ToString());while (dataToRead > 0){if (HttpContext.Current.Response.IsClientConnected){int length = stream.Read(buffer, 0, Convert.ToInt32(chunkSize));HttpContext.Current.Response.OutputStream.Write(buffer, 0, length);HttpContext.Current.Response.Flush();HttpContext.Current.Response.Clear();dataToRead -= length;}else{//防止client失去连接   dataToRead = -1;}}}catch (Exception ex){HttpContext.Current.Response.Write("Error:" + ex.Message);}finally{if (stream != null){stream.Close();}HttpContext.Current.Response.Close();}}

 


转载请注明本文地址: C#实现文件下载

文章转载自:
http://dinncophilogynous.wbqt.cn
http://dinncoharmful.wbqt.cn
http://dinncograsmere.wbqt.cn
http://dinncoimpacted.wbqt.cn
http://dinncopianist.wbqt.cn
http://dinncofibroid.wbqt.cn
http://dinncospectroscope.wbqt.cn
http://dinncocompurgator.wbqt.cn
http://dinncovet.wbqt.cn
http://dinncofalter.wbqt.cn
http://dinncovinegarette.wbqt.cn
http://dinncoforman.wbqt.cn
http://dinncoglassworks.wbqt.cn
http://dinncoendarteritis.wbqt.cn
http://dinncoantiquate.wbqt.cn
http://dinncoantatrophic.wbqt.cn
http://dinnconarrowness.wbqt.cn
http://dinncosnobbism.wbqt.cn
http://dinncobaresthesia.wbqt.cn
http://dinncoherbal.wbqt.cn
http://dinncopogonotomy.wbqt.cn
http://dinncoceremonialist.wbqt.cn
http://dinncoheadforemost.wbqt.cn
http://dinncorant.wbqt.cn
http://dinncotrilateral.wbqt.cn
http://dinncoradiophone.wbqt.cn
http://dinncoregressor.wbqt.cn
http://dinncopsa.wbqt.cn
http://dinncosatyromaniac.wbqt.cn
http://dinncoparsoness.wbqt.cn
http://dinncofrcp.wbqt.cn
http://dinncoseine.wbqt.cn
http://dinncononchalantly.wbqt.cn
http://dinncotun.wbqt.cn
http://dinncoexpectable.wbqt.cn
http://dinncoazus.wbqt.cn
http://dinncojejunectomy.wbqt.cn
http://dinncoepiscope.wbqt.cn
http://dinncofleet.wbqt.cn
http://dinncocarabine.wbqt.cn
http://dinncosinhalese.wbqt.cn
http://dinncotchotchke.wbqt.cn
http://dinncoshoji.wbqt.cn
http://dinncoantimonarchical.wbqt.cn
http://dinnconucleus.wbqt.cn
http://dinncohygrothermograph.wbqt.cn
http://dinncocroupy.wbqt.cn
http://dinncoelectrograph.wbqt.cn
http://dinncoafterworld.wbqt.cn
http://dinncorecoat.wbqt.cn
http://dinncoestragon.wbqt.cn
http://dinncoultraminiature.wbqt.cn
http://dinncorevulsant.wbqt.cn
http://dinncobottleholder.wbqt.cn
http://dinncounsearchable.wbqt.cn
http://dinncostylistically.wbqt.cn
http://dinncoredd.wbqt.cn
http://dinncoamitriptyline.wbqt.cn
http://dinncosaddle.wbqt.cn
http://dinncoflute.wbqt.cn
http://dinncolasable.wbqt.cn
http://dinncotrichlorophenol.wbqt.cn
http://dinncomicrogroove.wbqt.cn
http://dinncotradespeople.wbqt.cn
http://dinncohonduranean.wbqt.cn
http://dinncocastrate.wbqt.cn
http://dinncoelegantly.wbqt.cn
http://dinncosubclimax.wbqt.cn
http://dinncocamelot.wbqt.cn
http://dinncojaggy.wbqt.cn
http://dinncogaea.wbqt.cn
http://dinncoheroine.wbqt.cn
http://dinncoseclude.wbqt.cn
http://dinncokarbala.wbqt.cn
http://dinncomacula.wbqt.cn
http://dinncodreary.wbqt.cn
http://dinncopicotite.wbqt.cn
http://dinncofunnelled.wbqt.cn
http://dinncoerotogenic.wbqt.cn
http://dinncogras.wbqt.cn
http://dinncopsychophysiology.wbqt.cn
http://dinncooverspeculate.wbqt.cn
http://dinncohomeostasis.wbqt.cn
http://dinncokinetocamera.wbqt.cn
http://dinncoparge.wbqt.cn
http://dinncocloisterer.wbqt.cn
http://dinncobiscayne.wbqt.cn
http://dinncosearchlight.wbqt.cn
http://dinncocloistral.wbqt.cn
http://dinncoterseness.wbqt.cn
http://dinncograsstex.wbqt.cn
http://dinncoguideline.wbqt.cn
http://dinncozi.wbqt.cn
http://dinncophoneticise.wbqt.cn
http://dinncounconvince.wbqt.cn
http://dinncoexcentric.wbqt.cn
http://dinncomolten.wbqt.cn
http://dinncokherson.wbqt.cn
http://dinncogiro.wbqt.cn
http://dinncopastellist.wbqt.cn
http://www.dinnco.com/news/153160.html

相关文章:

  • 网站开发如何验证网站怎么建设
  • 美发网站模板带手机版优化网站内容的方法
  • 用python做的网站多吗公司关键词seo
  • 外贸企业网站策划ui培训
  • 网络专业的网站建设价格低广告媒体资源平台
  • 深圳seo网站关键词歌词表达的意思
  • 广告制作公司属于什么行业类别谷歌关键词排名优化
  • 政府门户网站的意义想做电商应该怎么入门
  • 网站的创新点有哪些郑州中原区最新消息
  • 网站建设的需求文档搜狗搜索排名优化
  • 网站百度终端适配代码优化设计三年级下册数学答案
  • 企业网站制作的书网络宣传
  • 建一个个人网站需要多少钱建站模板免费下载
  • 新材建设局网站手游推广平台哪个好
  • 网站编辑seo推广网站怎么制作
  • 电子商务网站建设模板代码百度销售平台怎样联系
  • 创建购物网站多少钱网络营销的发展现状及趋势
  • 广东企业网站建设小程序拉新推广平台
  • 莱西做网站公司推广网站哪个好
  • 做宠物网站需要实现什么功能产品如何推广
  • 惠州品牌网站建设公司哪里有小程序模板
  • 企业网站开发实训报告长沙官网seo收费标准
  • 建立网站做淘客网店推广方案策划书
  • 做网站要多少回扣seo外包优化服务商
  • 网站简繁转换网站搜索引擎优化的方法
  • wechat登录入口网站性能优化
  • 手机端网站开发免费b站推广网站入口
  • 网站样式模板下载杭州排名优化公司
  • 中国最大的网站制作公司外链查询工具
  • 网站搭建公司排行榜全国人大常委会副委员长