using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
namespace DemoWebClient
{
class Program
{
static void Main(string[] args)
{
const string filePath = @"1741270.html";
string localpath = @"c:\";
const string url = "http://www.cnblogs.com/downmoon/archive/2010/05/21/";
DownloadOneFileByURLWithWebClient(filePath, url, localpath);
Console.Read();
}
public static void DownloadOneFileByURLWithWebClient(string fileName, string url, string localPath)
{
System.Net.WebClient wc = new System.Net.WebClient();
if (File.Exists(localPath + fileName)) { File.Delete(localPath + fileName); }
if (Directory.Exists(localPath) == false) { Directory.CreateDirectory(localPath); }
wc.DownloadFile(url + fileName, localPath + fileName);
}
}
}
也可以参考:
http://www.cnblogs.com/downmoon/archive/2009/07/01/1514519.html
webbrowser用得不多,楼主可以看看它的事件,好像以前看到过有人可以屏蔽弹窗,同理,屏蔽下载也应该可以实现的.