I want to download a file from,
[Click Here](Here is the link : http://www33.zippyshare.com/v/67074373/file.html)

I got this code :

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

amd it works fine but my problem is that my application is automated and I want the wbebrowser download dialog to be hidden and file should be downloaded directly to the place I want.

Don't tell me to save the link as string and then download it through DownloadFile method as the link is autogenerated by zippyshare and I can only download it in same session or link will expire. which means i have to use the webbrowser, unless there is a way to get the .zip link by another method.

I don't care which language you can give me your answer :3, i need it to accept some arguments during startup (preferred c#, c++, vb) so I send the link over :3

please help me.

Recommended Answers

All 2 Replies

I used the following to download some files. Don't know if this will solve your issue, but it worked for me. It was in C# replace [] with the curly braces. Posting code is causing me fits

private bool FetchFDICFile(string urlAddress, string @location) [

        WebClient webClient = new WebClient();
        webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
        webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);

        // The variable that will be holding the url address (making sure it starts with https:// edit the code if it starts with http://)
        Uri URL = urlAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase) ? new Uri(urlAddress) : new Uri("https://" + urlAddress);       

        try [
            // Start downloading the file
            webClient.DownloadFileAsync(URL, location);
            return true;
        ]
        catch (Exception ex) [
            MessageBox.Show(ex.Message);
            return false;
        ]
    ]

Here is a VB.NET version of what gtcorwin had posted.

Hopefully this will alleviate any problems you may have converting the code.

Private Function TransferFile(ByVal sURLAddress As String) As Boolean
    Dim webClient As New WebClient()
    AddHandler webClient.DownloadFileCompleted, AddressOf DownloadComplete
    AddHandler webClient.DownloadProgressChanged, AddressOf ProgressChanged
    Dim URL As Uri = If(sURLAddress.StartsWith("https://", StringComparison.OrdinalIgnoreCase), _
                                   New Uri(sURLAddress), New Uri("https://" + sURLAddress))
    Try
        webClient.DownloadFileAsync(URL, "PathToMyDestination")
        Return True
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
        Return False
    Finally
        webClient.Dispose()
        URL = Nothing
    End Try
End Function

Private Sub DownloadComplete(ByVal sender As Object, e As AsyncCompletedEventArgs)
    Try
        'Do stuff
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
    End Try
End Sub

Private Sub ProgressChanged(ByVal sender As Object, e As DownloadProgressChangedEventArgs)
    Try
        'Do stuff
    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
    End Try
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.