program.cs
来自「断点续传,下载DEMO 是VS2008下写的,我收集的在这里共享给大家」· CS 代码 · 共 71 行
CS
71 行
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Security;
using System.Threading;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Data;
using Cblang.HttpDownload;
namespace Test_HttpDownload
{
class Program
{
static AutoResetEvent a = new AutoResetEvent(false);
static void Main(string[] args)
{
//如果使用代理服务器下载.请取消下行的注释
//WebRequest.DefaultWebProxy = new WebProxy("127.0.0.1:8118");
string url = @"http://zdit.cn/download/phonecard_h.rar";
string name = MD5Helper.MD5Encrypt(url);
//新建下载
DownloadFile df = new DownloadFile(url, @"e:\dh.rar", 5);
//断点续传请使用下面的构造
//DownloadFile df = new DownloadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, name));
df.Finished += new EventHandler(df_Finished);
Console.WriteLine("开始下载");
//开始下载....
df.Start();
while( true)
{
string command = Console.ReadLine();
if (command == "stop")
{
df.Stop();
}
else if (command == "start")
{
df.Start();
}
else if (command == "save")
{
df.Stop();
}
else if (command == "exit")
{
df.Stop();
Console.WriteLine("按任意键退出");
Console.ReadKey();
return;
}
}
// a.WaitOne();
}
static void df_Finished(object sender, EventArgs e)
{
Console.WriteLine("下载完成");
a.Set();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?