在VB中没有对话框的WebBrowser.FileDownload [英] WebBrowser.FileDownload without dialog in vb

查看:202
本文介绍了在VB中没有对话框的WebBrowser.FileDownload的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我的问题是zippyshare生成的链接仅适用于当前会话。所以,我希望webbrowser下载文件,但不显示对话框,因为它是一个下载文件的自动工具。



我尝试获取直接url文件和使用,



 My.Computer.Network.DownloadFile(dlurl,Application.StartupPath +   \ .123.zip





dlurl从哪里我得到了文件的url作为字符串。



我在从webbrowser下载文件之后和之前尝试过但是我的两个都失败了并且给了我一个该位置的0字节文件:/



它就像我只能从webbrowser会话下载。



  Dim  Str  As  字符串 =  .WebBrowser1.Document.GetElementById(  downloadB)。GetAttribute(  href
如果(Str.EndsWith( zip)) 然后
WebBrowser1.Navigate( http: //www33.zippyshare.com + Str)
结束 如果







这在c ++中可行吗?我需要先从webbrowser.document获取url,然后下载并保存。即使是控制台应用程序也会这样做,直到我能够获取ID,我必须使用webbrowser,所以我可以获得webbrowser.document来获取链接。



链接仅适用于该会话。如果我从中下载文件,让我们说chrome,然后将直接链接复制到Firefox,它将无法正常工作。但在chrome内部,我可以一次又一次地使用链接并下载它。

解决方案

使用System.Net;



WebClient Client = new WebClient();



string URL =Download URL

string FilePath = Server.MapPath( 〜/ FolderName /);

string FileName =test;



Client.DownloadFile(new Uri(URL),FilePath +文件名);

Hello, my problem here is that zippyshare generates links that only works with that current session. So, I want the webbrowser to download the file, but not show the dialog as it is a automated tool to download files.

I tried getting the direct url to file and using,

My.Computer.Network.DownloadFile(dlurl, Application.StartupPath + "\123.zip")



dlurl from where i got the url of file as string.

I tried it after and before downloading the file from webbrowser but my bad both of them failed and returned me a 0 bytes file in that location :/

Its like i can only download from the webbrowser session.

Dim Str As String = Me.WebBrowser1.Document.GetElementById("downloadB").GetAttribute("href")
        If (Str.EndsWith("zip")) Then
            WebBrowser1.Navigate("http://www33.zippyshare.com" + Str)
        End If




Is this possible in c++ ? I need to first get the url from webbrowser.document and then download it and save it. Even console applications will do till I am able to get the ID, i had to use the webbrowser so i can get the webbrowser.document to get the link.

Links only work with that session. If I download the file from, lets say chrome, and then copy the direct link to firefox it won't work. but inside chrome i can use the link again and again and download it.

解决方案

using System.Net;

WebClient Client = new WebClient();

string URL="Download URL"
string FilePath = Server.MapPath("~/FolderName/");
string FileName= "test";

Client.DownloadFile(new Uri(URL), FilePath + FileName);


这篇关于在VB中没有对话框的WebBrowser.FileDownload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆