Page 1 of 2

HELP! Download thing

Posted: Sun Feb 21, 2010 1:29 pm
by NeedHelp
I need help making a downloading thing like this:

Image

For example:
You click on Download 1 and it downloads the file to the desktop [the progressbar and the % thing have to work to]

Download 1,2 and 3 has different download links...


^NeedHelp

Re: HELP! Download thing

Posted: Sun Feb 21, 2010 9:23 pm
by Scottie1972
First off....You need to figure out how you are going to populate the ComboBox.
Are you using a datasource, textfile, XML file, or are you going to hard code the links in the ComboBox.

As far as downloading from the link. There a several ways of doing it.
But! If this is a software that you entend on letting others use this project you have to think about Firewall issues.

Scottie

Re: HELP! Download thing

Posted: Sun Feb 21, 2010 9:31 pm
by NeedHelp
I'm going to use a stg file [list.stg]
Code: Select all
[Download 1]
site=http://xxx.

[Download 2]
site=http://xxx.

[Download 3]
site=http://xxx.  
But i'm open to use something else...

Re: HELP! Download thing

Posted: Sun Feb 21, 2010 9:34 pm
by Scottie1972
OK!
So what type of files will be downloaded?
Is this for a Update feature for a project?
Is this just an app from users to download what ever you are offereing?

These are questions you need to think about.

Re: HELP! Download thing

Posted: Sun Feb 21, 2010 9:37 pm
by NeedHelp
Download .exe files.
Users download what i am offering

Re: HELP! Download thing

Posted: Sun Feb 21, 2010 9:42 pm
by Scottie1972
Code: Select all
My.Computer.Network.DownloadFile(ComboBox1.SelectedItem, My.Computer.FileSystem.SpecialDirectories.Desktop + "\" + "FILENAME.EXT")
The FILENAME.EXT needs to be the original filename that is being downloaded

This will download the file to the user Desktop

Re: HELP! Download thing

Posted: Sun Feb 21, 2010 10:16 pm
by NeedHelp
The file is .exe and how about the other stuff

Re: HELP! Download thing

Posted: Sun Feb 21, 2010 10:20 pm
by Scottie1972
From what I can tell, you have to use a BackgroundWorker to download the file and as the file downloads, it updates the ProgressBar. I personaly do not how todo this with a BackGroundWorker. Do a Google search on BackgroundWorker Downloadfile in vb.net or vb 2008. See what you come up with.

Re: HELP! Download thing

Posted: Mon Feb 22, 2010 1:40 am
by CodenStuff
Hello,

To do a progress bar you could use this:

First the part the downloads the file:
Code: Select all
Dim WebUpdate As System.Net.WebClient
                WebUpdate = New System.Net.WebClient()
                AddHandler WebUpdate.DownloadProgressChanged, AddressOf OnDownloadProgressChanged2
                AddHandler WebUpdate.DownloadFileCompleted, AddressOf OnFileDownloadCompleted2
                WebUpdate.DownloadFileAsync(New Uri("FILE URL HERE"), "SaveFileAsName.exe")
Then just add these subs in your code:
Code: Select all
Private Sub OnDownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs)
        Dim totalSize As Long = e.TotalBytesToReceive
        Dim downloadedBytes As Long = e.BytesReceived
        Dim percentage As Integer = e.ProgressPercentage
        ProgressBar1.Increment(percentage)
    End Sub


    Private Sub OnFileDownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
        If e.Cancelled Then
        ElseIf Not e.Error Is Nothing Then
            'FILE CANNOT BE DOWNLOADED - DO SOMETHING HERE
        Else
        'FILE HAS DOWNLOADED SUCCESSFULLY - DO SOMETHING HERE
        End If
    End Sub
Hope that helps cooll;

Re: HELP! Download thing

Posted: Mon Feb 22, 2010 2:20 am
by Scottie1972
Thanks CodenStuff, this example helped me out.