摘要: 多线程,分块下载。using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{class Program{//准备了一个用来保存的文件流。static FileStream fs;static void Main(string[] args){Thread t = new Thread(new ThreadStart(Down));t.Start();}static voi 阅读全文
posted @ 2011-03-02 00:04 愤怒的熊猫 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 为了解决那些个把下载过程中的byte数组,要拿去自行处理的变态们,俺特地做了下面的更改。using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{class Program{//准备了一个用来保存的文件流。static FileStream fs;static void Main(string[] args){fs = new FileStream("c:\\e 阅读全文
posted @ 2011-03-02 00:03 愤怒的熊猫 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 收拾那些只要byte数组,不要当场保存的变态用户。using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{class Program{static void Main(string[] args){//在构造时可以不填写url和fileName//在下载的时候再填写。DownloadUtil du = new DownloadUtil();//订阅事件du.ReadCo 阅读全文
posted @ 2011-03-02 00:02 愤怒的熊猫 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 可以自定义要下载的url和要保存的文件名。using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{class Program{static void Main(string[] args){//实例化下载工具//要求用户在使用的时候,填入url和fileNameDownloadUtil du = new DownloadUtil("http://blog.si 阅读全文
posted @ 2011-03-01 23:08 愤怒的熊猫 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 将要下载的url和fileName的传递从构造中转移到DownloadData方法中,给用户以更大的灵活性。using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{class Program{static void Main(string[] args){//在构造时可以不填写url和fileName//在下载的时候再填写。DownloadUtil du = new D 阅读全文
posted @ 2011-03-01 23:08 愤怒的熊猫 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 把信号机隐藏起来,让调用方干净一点。using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{class Program{static void Main(string[] args){//实例化下载工具DownloadUtil du = new DownloadUtil();//订阅事件du.ReadCompleted += new ReadCompletedHandl 阅读全文
posted @ 2011-03-01 23:07 愤怒的熊猫 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 简单封装:using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{class Program{static void Main(string[] args){//信号机AutoResetEvent are = new AutoResetEvent(false);//实例化下载工具DownloadUtil du = new DownloadUtil();du.are = 阅读全文
posted @ 2011-03-01 23:06 愤怒的熊猫 阅读(126) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{//读取完成委托delegate void ReadCompletedHandler();class Program{//添加一个AutoResetEvent//这是一个信号机static AutoResetEvent are = new AutoResetEvent(false);//读取完成事件static e 阅读全文
posted @ 2011-03-01 23:05 愤怒的熊猫 阅读(131) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{//读取完成委托delegate void ReadCompletedHandler();//读取过程委托delegate void ReadProgressHandler(int x);class Program{//添加一个AutoResetEvent//这是一个信号机static AutoResetEvent 阅读全文
posted @ 2011-03-01 23:05 愤怒的熊猫 阅读(125) 评论(0) 推荐(0) 编辑
摘要: using System;using System.Collections.Generic;using System.Text;using System.Net;using System.IO;using System.Threading;namespace prjDownLoad{class Program{//添加一个AutoResetEvent//这是一个信号机static AutoResetEvent are = new AutoResetEvent(false);static void Main(string[] args){//Version8.0//将下载数据放入线程池中。Thr 阅读全文
posted @ 2011-03-01 23:04 愤怒的熊猫 阅读(104) 评论(0) 推荐(0) 编辑