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

网站建设托管产品图广东全网营销与推广公司

网站建设托管产品图,广东全网营销与推广公司,wordpress怎么建立下载,为什么要建设营销型网站在这里我用了一个线程池#xff0c;线程池参数接收一个带有object参数的#xff0c;无返回值的委托 #xff0c;下载用到的核心代码#xff0c;网上拷贝的#xff0c;他的核心就是发起一个web请求#xff0c;然后得到请求的响应#xff0c;读取响应的流 剩下的都是常见的…在这里我用了一个线程池线程池参数接收一个带有object参数的无返回值的委托 下载用到的核心代码网上拷贝的他的核心就是发起一个web请求然后得到请求的响应读取响应的流 剩下的都是常见的IO操作       由于线程池接参数的委托接收一个object参数。所以我把请求地址和本地存放地址以及名字封装了一个类用来传参    这是下载工具代码如下 using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Net; using UnityEngine;public class DownLoaderEnum {public string url;public string path;public DownLoaderEnum(string URL, string PATH){url URL;path PATH;} }public class HttpDownload {/// summary/// http下载文件/// /summary/// param nameurl下载文件地址/param/// param namepath文件存放地址包含文件名/param/// returns/returnspublic void HttpDownloader(object down){if (!Directory.Exists((down as DownLoaderEnum).path))Directory.CreateDirectory((down as DownLoaderEnum).path);string tempPath System.IO.Path.GetDirectoryName((down as DownLoaderEnum).path) \temp;System.IO.Directory.CreateDirectory(tempPath); //创建临时文件目录string tempFile tempPath \ System.IO.Path.GetFileName((down as DownLoaderEnum).path) .temp; //临时文件if (System.IO.File.Exists(tempFile)){System.IO.File.Delete(tempFile); //存在则删除}try{FileStream fs new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);// 设置参数HttpWebRequest request WebRequest.Create((down as DownLoaderEnum).url) as HttpWebRequest;//发送请求并获取相应回应数据HttpWebResponse response request.GetResponse() as HttpWebResponse;//直到request.GetResponse()程序才开始向目标网页发送Post请求Stream responseStream response.GetResponseStream();//创建本地文件写入流//Stream stream new FileStream(tempFile, FileMode.Create);byte[] bArr new byte[1024];int size responseStream.Read(bArr, 0, (int)bArr.Length);while (size 0){//stream.Write(bArr, 0, size);fs.Write(bArr, 0, size);size responseStream.Read(bArr, 0, (int)bArr.Length);}//stream.Close();fs.Close();responseStream.Close();string suffixName (down as DownLoaderEnum).url;int su suffixName.LastIndexOf(/);suffixName (down as DownLoaderEnum).pathsuffixName.Substring(su);// Debug.LogError(suffixName);System.IO.File.Move(tempFile, suffixName);// return true;Debug.LogError(下载完成);}catch (Exception ex){Debug.LogError(错误 ex.Message);//return false;}} }这是测试代码 using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Threading; using UnityEngine;public class NewBehaviourScript : MonoBehaviour {public string url http://dl172.80s.im:920/1802/[比得兔]剧场预告片/[比得兔]剧场预告片_hd.mp4;// Use this for initializationstring path ;HttpDownload download new HttpDownload();DownLoaderEnum down;private void Awake(){path Application.streamingAssetsPath;//DirectoryInfo directory new DirectoryInfo(path);//if (directory.Exists)// directory.Create();//Debug.LogError(path);}// Use this for initializationvoid Start(){ThreadPool.SetMaxThreads(5, 5);down new DownLoaderEnum(url, path);//请求url存放地址存放文件名}// Update is called once per framevoid Update(){if (Input.GetKeyDown(KeyCode.Space)){ThreadPool.QueueUserWorkItem(download.HttpDownloader, down);}} }可以看到已经下载完成  转载于:https://www.cnblogs.com/lzy575566/p/8458867.html
http://www.lebaoying.cn/news/11782.html

相关文章:

  • 网站备案 接入商卢氏县网站建设推广
  • 学校 html5 网站 案例做网站源码需要多少钱
  • 亚网站建设wordpress如何站点
  • 怎么做微信推送 网站做网站刷QQ会员网站
  • 建设99网站小程序模板库
  • 企业网站分析报告湖北做网站找谁
  • 为什么有网网站打不开怎么回事wordpress随机增加阅读量
  • 是阿里巴巴好还是自己做网站好?在电商网站上做推广的技巧
  • 建筑用塑料模板价格seo优化方向
  • 育婴网站模板网站怎么做留言板
  • 网站301跳转有坏处吗惠州网站建设怎么样
  • 营销型网站建设xywlcn成都有什么好玩的
  • 江西建设工程质量管理网站查询网站备案密码是什么情况
  • 重庆做网站优化网站建设一般需要什么功能
  • 沈阳制作公司网站和app高级私人定制制衣店
  • 百度站长平台安卓版一台服务器如何做两个网站
  • 网站怎么进何谓网络营销
  • 常见的pc端网站布局主流开发工具有哪些
  • 网站抽奖模块怎么做网站开发公司哪里寻找客源
  • 宁德网站建设公司个人网站怎么做cps
  • 惠州网站制作网站长沙58同城招聘网最新招聘
  • 装修公司网站怎么做中国机械加工网官方网站
  • 怎样自己弄一个网站网站开发公司凭证
  • 二手房公司如何做网站网站推广分为哪几个部分
  • 长春网站建设开发维护网站建设方案策划
  • 义乌制作网站开发网站托管服务合同范本
  • 西宁做网站的公司力请君博d在线图片编辑器图片编辑
  • 麻城网站建设网络推广公司招聘
  • 网站建设 知乎ip代理池
  • logo设计网站知乎效果好的网站制作