一个关于WebClient与 WebBrowser

WebBrowser wb = new WebBrowser();
wb.ScriptErrorsSuppressed = true;
//在这里Navigate一个空白页面
wb.Navigate("about:blank");
//获取html
System.Net.WebClient wc = new WebClient();
string htmlcode = wc.DownloadString(url);

//下载文件 一定要用 Directory.GetCurrentDirectory()

string filenames = Path.GetFileName("http://img1.gtimg.com/news/pics/hv1/14/174/1057/68775809.jpg");
wc.DownloadFile("http://img1.gtimg.com/news/pics/hv1/14/174/1057/68775809.jpg", Directory.GetCurrentDirectory()+"/image/" + filenames);

posted @ 2012-06-07 15:30  明天的太阳  阅读(196)  评论(0编辑  收藏  举报