📄 program.cs
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -