首页 新闻 会员 周边

webbrowser 问题求解

0
悬赏园豆:20 [已关闭问题]

在使用webbrowser访问网页中某个连接时,怎样管理文件下载存放位置或者屏蔽文件下载对话框。

网上也找了,没找到合适的答案,麻烦知道的朋友帮帮忙。

codingspace的主页 codingspace | 初学一级 | 园豆:179
提问于:2010-05-27 20:17
< >
分享
其他回答(1)
0
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

邀月 | 园豆:25475 (高人七级) | 2010-05-27 22:02
谢谢你的解答: 但是我的意思是使用webbrowser来模拟网页操作,下载文件的方式除了你上面用的webclient,还有httpRequest,不是我想要的结果。现在很多网站,文件下载链接不能直接得到的,所以我用了webbrowser,不知道你能不能提供webbrowser对js返回的文件进行管理或者屏蔽下载文件。
支持(0) 反对(0) codingspace | 园豆:179 (初学一级) | 2010-05-27 23:43
@codingspace:这个目前没有通用的思路,你需要先登录该页面,手工分析某个页面的特征,先下载部分,得到真实的地址。但也只限于特定网站和特定类型。如 flv解析等。而flashget有时也无法得到得到真实地址。
支持(0) 反对(0) 邀月 | 园豆:25475 (高人七级) | 2010-05-28 08:12
0

webbrowser用得不多,楼主可以看看它的事件,好像以前看到过有人可以屏蔽弹窗,同理,屏蔽下载也应该可以实现的.

I,Robot | 园豆:9783 (大侠五级) | 2010-05-31 17:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册