Moustached Monkey
Moustached Monkey

Reputation: 101

VB .exe file download

I am creating a project in VB, it has a files downloader, it works fine with files like .txt or images but when I try to download an .exe, the .exe turns to corrupted file, I mean, the program only download 1 Kb of the file and its impossible to execute it.

I'm using this code:


My.Computer.Network.DownloadFile(
    "http://www.web.domain/Archive.exe",
    "C:\Archive.exe")

I am working in 2013 VS version.

Upvotes: 0

Views: 1756

Answers (1)

Moustached Monkey
Moustached Monkey

Reputation: 101

YAY!!! I found a solution:

There it is ^^. Thank you for the answers.


Private Sub download_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles     Download.Click
    Download.Enabled = False
    httpclient = New WebClient
    AddHandler httpclient.DownloadFileCompleted, AddressOf Downloaded

    httpclient.DownloadFileAsync(New Uri("https://www.dropbox.com/s/2ch4prhn063hmxs/vanilla.exe?dl=1"), ("C:\BarberLand\downloads\Vanilla\vanilla.exe"))
End Sub

Private Sub dpc(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles httpclient.DownloadProgressChanged
    porcentaje.Text = e.ProgressPercentage
End Sub

Private Sub Downloaded()
    'Comprueba si el fichero se ha descargado completamente.
    If System.IO.File.Exists("C:\BarberLand\downloads\Vanilla\vanilla.exe") = True Then

        Process.Start("C:\BarberLand\downloads\Vanilla\vanilla.exe")
        Me.Close()
    Else
        MsgBox("El fichero no existe, pruebe con otra versión o si piensa que es un error, contácte con el administrador", 64, "Open")
    End If

End Sub

Upvotes: 1

Related Questions