Du bist hier Falsch.
In welcher Sprache willst du das realisieren?
Mit vb.net geht es z.B. so:
Code:
Imports System.Net
Public Class Form1
Private WithEvents httpclient As WebClient
Dim Pfad As String = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Hide()
ShowDialog:
SaveFileDialog1.ShowDialog()
If SaveFileDialog1.FileName = Nothing Then
GoTo ShowDialog
End If
Pfad = SaveFileDialog1.FileName
Try
Me.Show()
httpclient = New WebClient
Dim URL As String = "Link zur neuen .EXE"
Application.DoEvents()
httpclient.DownloadFileAsync(New Uri(URL), Pfad)
Application.DoEvents()
Catch ex As Exception
MsgBox("Es ist folgender Fehler aufgetreten:" & vbNewLine & ex.ToString, MsgBoxStyle.Critical, "Fehler!")
End
End Try
End Sub
Private Sub httpclient_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles httpclient.DownloadFileCompleted
MsgBox("Die aktuelle Version der Anwendung wurde im angegebenen Verzeichnis gespeichert", MsgBoxStyle.Information, "Update erfolgreich")
Shell(Pfad)
End
End Sub
Private Sub httpclient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles httpclient.DownloadProgressChanged
Me.ProgressBar1.Value = e.ProgressPercentage
Dim totalbytes As Double = e.TotalBytesToReceive / 1024
Dim bytes As Double = e.BytesReceived / 1024
Me.Label1.Text = bytes & "KB von" & totalbytes
End Sub
End Class