Download, get the filename and execute the file

  • Thread starter Thread starter urakenzey
  • Start date Start date
U

urakenzey

Guest
Hello,

I am posting here to ask you for help, thank you first of all for reading my message and being able to help me. :)

So here's the problem, I have a little program that I'm creating, in this one, I integrated a button that normally allows to download a tool to run it.

However the link of the file does not point directly in .exe it is a link like this one : mydomain.com/file/file48.php

The problem is that I manage to get the file, but this one is named file48.php and gets the extension of a php file, what I would like is to get the original name of the downloaded .exe file in order to be able to execute it within my application.

Here is the current code I'm using :


Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim client As New WebClient

AddHandler client.DownloadFileCompleted, AddressOf client_DownloadFileCompleted

client.DownloadFileAsync(New Uri("https ://mydomain.com/files/index.php"), fileName, filename)
End Sub

Private Sub client_DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs)
Dim client = DirectCast(sender, WebClient)

client.Dispose()

Dim filename As String = CType(e.UserState, String)
End Sub

Thanks a lot for your help, I've been searching for hours without much success...


Continue reading...
 
Back
Top