Lightbulb[Request] Simple download code

Posts 1–10 of 10 · Page 1 of 1
[Request] Simple download code
I am requesting a VERY simple code as a Sub for VB 2008 Express

It needs to be able to download a file (dll) from a Url and save it to a location on the computer (Application.StartupPath)

Thank You in advance

Im making a program based off Project TM

It downloads and injects hacks then deletes the hack so there is no leftover waste.

I need it ASAP

Thanks...
Code:
Dim webclnt as new system.net.webclient

Webclint.downloadfile(URL, Location)
Quote Originally Posted by wtfiwantthatname View Post
The urldownloadtoFile() api.

Someone asking how to download a file should not use zny API or Webservice

Further more, UrlFileDownload doesn't Work in VB.NET , It's VB6 Code.

Vb.net alternative.

Code:
WebClient.DownloadFile
Thanks lolland,

However I get an error "An exception occurred during a WebClient request."

___ Upon looking farther i found "Access to the path 'C:\Users\Admin\Desktop' is denied.

with

Code:
webclient.DownloadFile("http://1.bp.blog!spot.com/_l8ZBsSeLPxk/R0uUWcxCOqI/AAAAAAAAAig/nyUgKA4iGmw/s400/921-i_love_you_teddy_bear.jpg", "C:\Users\Admin\Desktop")
There is no ! between blog and spot. ^^

Im not familiar with I/O streams and am not sure how to fix it...

- snotpig
Run as admin.
Quote Originally Posted by Lolland View Post
Run as admin.
You can't do that in VB and I tried building the program and running that as admin but it still has the same error...

I changed it to

Code:
webclient.DownloadFile("http://1.bp.blog!spot.com/_l8ZBsSeLPxk/R0uUWcxCOqI/AAAAAAAAAig/nyUgKA4iGmw/s400/921-i_love_you_teddy_bear.jpg", Application.StartupPath)
In your code you are forgetting to give the image you downloaded (or file) a name, Plus I tested that link and I didnt see an image.

In either case, here is my code, works fine

'NameSpace

Code:
Imports System.Net
Next, Create a Sub called DGoogLogo

Code:
Private Sub DGoogLogo
       
    End Sub
Next, Inside DGoogLogo Sub add this code

Code:
'Create a New WebClient       
Dim wcli As Net.WebClient = New Net.WebClient
'Set The Location Of The File
Dim location As String = "http://vhirsch.com/blog/wp-content/uploads/2009/11/google_logo5.jpg"
' Finally Download The File.
wcli.DownloadFile(location, "c:\test\google_logo5.jpg")
Your code should look like this.

Code:
Private Sub DGoogLogo()
        Dim wcli As Net.WebClient = New Net.WebClient
        Dim location As String = "http://vhirsch.com/blog/wp-content/uploads/2009/11/google_logo5.jpg"
        wcli.DownloadFile(location, "c:\test\google_logo5.jpg")
    End Sub
Now Where ever you want Call DGoogLogo

For my purposes I will do it on the Form_Load Event

Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        
           DGooglogo()

    End Sub
Now if you run the project and check the C:\test folder you will find a google logo PNG



'It Looks like a lot, but that is only because I wanted to explain it, the code for this should be as small as this.

Imports System.Net

Public Class Form1

Private Sub DoDownload()
Dim wcli As Net.WebClient = New Net.WebClient
Dim location As String = "http://vhirsch.com/blog/wp-content/uploads/2009/11/google_logo5.jpg"
wcli.DownloadFile(location, "c:\test\google_logo5.jpg")
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DoDownload()
End Sub
End Class



Hope this helps
Thanks NextGen1,

Ive been working on it and i noticed that instead of a file path such as Application.Startuppath I should give it a name instead and it worked.

Then I came back here and found that you came to the same conclusion.
Code:
Dim webclient As New System.Net.WebClient
Code:
Dim H1Url As String = http://bizbox.slate.com/blog/google.jpg"
Code:
webclient.DownloadFile(H1Url, "Google.jpg")
Thanks for everyones help
Not a problem, it is what we are here for (mostly)
Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?