unity3d迅雷下到一半不动了关机了

下载英雄联盟不小心关机了怎么办?在腾讯游戏平台下载到百分之九十八的时候,不小心关机了,怎么从九十八_百度知道百度知道 - 信息提示
知道宝贝找不到问题了&_&!!
该问题可能已经失效。
秒以后自动返回2185人阅读
Unity3D(129)
using UnityE
using System.C
using System.IO;
using System.N
using Math= System.M
using Uri = System.U
using Convert= System.C
public class DownloadTest : MonoBehaviour
public UILabel label1;
public UILabel label2;
// Use this for initialization
void Start ()
// Update is called once per frame
void Update ()
void OnGUI ()
if (GUI.Button (new Rect (0, 0, 100, 20), &Download&)) {
StartCoroutine (downfile (&http://localhost:8888/test.zip&, Application.streamingAssetsPath + &/test.zip&, label1));
if (GUI.Button (new Rect (0, 20, 100, 20), &StopDownload&)) {
StopAllCoroutines ();
if (GUI.Button (new Rect (0, 40, 100, 20), &ResumDownload&)) {
StartCoroutine (FPointDown (&http://localhost:8888/test.zip&, Application.streamingAssetsPath + &/test.zip&, label2));
string t = &&;
//整体下载
IEnumerator downfile (string url, string LocalPath, UILabel DesLable)
Uri u = new Uri (url);
HttpWebRequest mRequest = (HttpWebRequest)WebRequest.Create (u);
mRequest.Method = &GET&;
mRequest.ContentType = &application/x-www-form-urlencoded&;
HttpWebResponse wr = (HttpWebResponse)mRequest.GetResponse ();
Stream sIn = wr.GetResponseStream ();
FileStream fs = new FileStream (LocalPath, FileMode.Create, FileAccess.Write);
long length = wr.ContentL
long i = 0;
decimal j = 0;
while (i&length) {
byte[] buffer = new byte[1024];
i += sIn.Read (buffer, 0, buffer.Length);
fs.Write (buffer, 0, buffer.Length);
if ((i % 1024) == 0) {
j = Math.Round (Convert.ToDecimal ((Convert.ToDouble (i) / Convert.ToDouble (length)) * 100), 4);
t = &当前下载文件大小:& + length.ToString () + &字节当前下载大小:& + i + &字节下载进度& + j.ToString () + &%&;
DesLable.text = t.ToString ();
t = &当前下载文件大小:& + length.ToString () + &字节当前下载大小:& + i + &字节&;
DesLable.text = t.ToString ();
sIn.Close ();
wr.Close ();
fs.Close ();
string downloadString = &已经下载&;
//断点下载
IEnumerator FPointDown (string uri, string saveFile, UILabel DesLable)
//打开网络连接
HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create (uri);
HttpWebRequest requestGetCount = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create (uri);
long countLength = requestGetCount.GetResponse ().ContentL
//打开上次下载的文件或新建文件
long lStartPos = 0;
System.IO.FileS
if (System.IO.File.Exists (saveFile)) {
fs = System.IO.File.OpenWrite (saveFile);
lStartPos = fs.L
if (countLength - lStartPos &= 0) {
fs.Close ();
t = &已经&;
DesLable.text = t.ToString ();
fs.Seek (lStartPos, System.IO.SeekOrigin.Current);//移动文件流中的当前指针
fs = new FileStream (saveFile, FileMode.Create);
if (lStartPos & 0) {
request.AddRange ((int)lStartPos);//设置Range值
print (lStartPos);
//向服务器请求,获得服务器回应数据流
Stream ns = request.GetResponse ().GetResponseStream ();
int len = 1024 * 8;
byte[] nbytes = new byte[len];
int nReadSize = 0;
nReadSize = ns.Read (nbytes, 0, len);
while (nReadSize&0) {
fs.Write (nbytes, 0, nReadSize);
nReadSize = ns.Read (nbytes, 0, len);
t = downloadString + &:& + fs.Length / 1024 + &kb/& + countLength / 1024 + &kb& + &----& + ((double)fs.Length / countLength).ToString () + &%&;
DesLable.text=t;
ns.Close ();
fs.Close ();
//这里放更新***代码,或者可以测试这个下载的包有没有出错,验证sha和md5
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:694469次
积分:7900
积分:7900
排名:第1830名
原创:100篇
转载:85篇
评论:287条
(2)(2)(16)(2)(1)(2)(1)(1)(7)(10)(2)(8)(4)(7)(2)(8)(6)(3)(1)(3)(11)(9)(8)(21)(5)(11)(12)(4)(14)(12)

参考资料

 

随机推荐