HELP! Download thing

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
16 posts Page 1 of 2
Contributors
User avatar
NeedHelp
Member
Member
Posts: 42
Joined: Fri Feb 19, 2010 3:57 pm

HELP! Download thing
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
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: HELP! Download thing
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
Image
User avatar
NeedHelp
Member
Member
Posts: 42
Joined: Fri Feb 19, 2010 3:57 pm

Re: HELP! Download thing
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...
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: HELP! Download thing
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.
Image
User avatar
NeedHelp
Member
Member
Posts: 42
Joined: Fri Feb 19, 2010 3:57 pm

Re: HELP! Download thing
NeedHelp
Download .exe files.
Users download what i am offering
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: HELP! Download thing
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
Image
User avatar
NeedHelp
Member
Member
Posts: 42
Joined: Fri Feb 19, 2010 3:57 pm

Re: HELP! Download thing
NeedHelp
The file is .exe and how about the other stuff
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: HELP! Download thing
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.
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: HELP! Download thing
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;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: HELP! Download thing
Scottie1972
Thanks CodenStuff, this example helped me out.
Image
16 posts Page 1 of 2
Return to “Tutorial Requests”