C#使用WebResponse实现断点续传
来源:互联网 发布:115 mac 离线 编辑:程序博客网 时间:2024/06/05 05:33
代码如下,最好还需要加上文件版本判断,确定是不是同一个文件,不要是牛头马面了
fileStream = new FileStream(Path,FileMode.Append,FileAccess.Write); inStream = null; try { HttpWebRequest myre=(HttpWebRequest)WebRequest.Create(URL); if(fileStream.Length == myre.ContentLength) { MessageBox.Show("你以完成下载该程序了","ok"); return; } myre.AddRange(Convert.ToInt32(fileStream.Length));//接上次下载的字节开始下载文件 HttpWebResponse response = (HttpWebResponse)myre.GetResponse(); inStream =response .GetResponseStream(); this.progressBar1.Maximum = total; this.progressBar1.Minimum =0; int length = 1024; byte[] buffer = new byte[1025]; int readerLength = 0,currentLength=0; while((readerLength =inStream.Read(buffer,0,length))> 0) { currentLength += readerLength ; fileStream.Write(buffer,0,readerLength); this.progressBar1.Value =currentLength + countByte; } fileStream.Close(); inStream.Close(); File.Delete(Application.StartupPath +@"\FileLength.txt"); MessageBox.Show("down 成功","ok");
- C#使用WebResponse实现断点续传
- 使用Visual C#实现断点续传
- 使用Visual C#实现断点续传
- 使用Visual C#实现断点续传
- 使用Visual C#实现断点续传
- 使用Visual C#实现断点续传
- 使用Visual C#实现断点续传
- 使用Visual C#实现断点续传
- 使用Visual C#实现断点续传
- 使用Visual C#实现断点续传
- 忆龙2009:使用Visual C#实现断点续传
- c#实现断点续传
- C#中实现断点续传
- c#实现断点续传
- c# 实现多线程断点续传
- 使用.NET实现断点续传
- 使用.NET实现断点续传
- 使用.NET实现断点续传
- 学习技术的三部曲:WHAT、HOW、WHY
- 修改DEDE登陆验证;
- Code Review中的几个提示
- WIN7系统的本子射出WIFI热点
- 改良程序的11技巧
- C#使用WebResponse实现断点续传
- UIViewController的生命周期图
- Malware Persistence without the Windows Registry
- 收藏 Visual Studio 2010 瘦身精简方法
- 如何在QT下执行shell或外部程序
- Qt paintevent 事件
- QStringList类常用方法
- NHibernate 查看生成的sql语句的方法
- 深入理解const char*p,char const*p,char *const p,const char **p,char const**p,char *const*p,char**const p