Ich wollte mir fürn Game einen Patcher erstellen, soweit hat alles geklappt nur kommt er bei einer bestimmten stelle nicht weiter.
Code:
Imports System.IO
Imports System.Security.Cryptography
Public Class Form1
Dim PATCHURL As String = "http://www.quantum2.de/patch"
Dim PATCHLIST As String = "http://www.quantum2.de/patchlist.xml"
Dim AppPath As String = My.Computer.FileSystem.CurrentDirectory
Dim WithEvents PatchDownloader As New System.Net.WebClient
Dim WithEvents PatchListDownloader As New System.Net.WebClient
Dim DLURLS As New List(Of String)
Dim ANZAHLDLS As Integer = 0
Dim Busy As Boolean = Nothing
Public Function MD5FileHash(ByVal sFile As String) As String
Dim MD5 As New MD5CryptoServiceProvider
Dim Hash As Byte()
Dim Result As String = ""
Dim Tmp As String = ""
Dim FN As New FileStream(sFile, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
MD5.ComputeHash(FN)
FN.Close()
Hash = MD5.Hash
For i As Integer = 0 To Hash.Length - 1
Tmp = Hex(Hash(i))
If Len(Tmp) = 1 Then Tmp = "0" & Tmp
Result += Tmp
Next
Return Result
End Function
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
lbl_aktuelledatei.Text = "Starte Patchvorgang..."
BG_List.RunWorkerAsync()
End Sub
Private Sub BG_List_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BG_List.DoWork
PatchListDownloader.DownloadFileAsync(New Uri(PATCHLIST), AppPath & "\patchlist.xml")
End Sub
Private Sub PatchListDownloader_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles PatchListDownloader.DownloadFileCompleted
lbl_aktuelledatei.Text = "Patchlist heruntergeladen. Starte nun das Patchen."
PB_AktuDatei.Value = 0
PB_GSM.Value = 0
BG_Patcher.RunWorkerAsync()
End Sub
Private Sub BG_Patcher_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BG_Patcher.DoWork
If BG_Patcher.CancellationPending = True Then
BG_Patcher.CancelAsync()
End If
Try
Dim xDocument As New Xml.XmlDocument
xDocument.Load(AppPath & "\patchlist.xml")
lbl_aktuelledatei.Text = "Starte nun das Patchen"
For Each node As Xml.XmlNode In xDocument.SelectNodes("Dateien/Datei")
Dim DateiPfad As String = AppPath & "\" & node.Attributes("Dateiname").InnerText
Dim Checksum As String = node.Attributes("Checksum").InnerText
Dim Check As Boolean = Nothing
lbl_aktuelledatei.Text = "Prüfe: " & node.Attributes("Dateiname").InnerText
If File.Exists(DateiPfad) = False Then
DLURLS.Add(PATCHURL & node.Attributes("Dateiname").InnerText.Replace("\", "/"))
Else
If Checksum = MD5FileHash(DateiPfad) Then
Check = True
Else
DLURLS.Add(PATCHURL & node.Attributes("Dateiname").InnerText.Replace("\", "/"))
Check = False
End If
End If
Next
ANZAHLDLS = DLURLS.Count
PB_GSM.Maximum = ANZAHLDLS
PB_GSM.Value = 0
Catch ex As Exception
End Try
Do
Try
If PatchDownloader.IsBusy = True Then
Busy = True
Else
For Each DownloadDatei In DLURLS
If IsNothing(DownloadDatei) Then Exit Do
Do
If Busy = False Then
lbl_aktuelledatei.Text = "Patche: " & IO.Path.GetFileName(DownloadDatei)
Dim SpeicherOrt As String = My.Computer.FileSystem.CurrentDirectory & "\" & DownloadDatei.Replace(PATCHURL, "").Replace("/", "\")
Dim Uri As New Uri(DownloadDatei)
If File.Exists(SpeicherOrt) = True Then
File.Delete(SpeicherOrt)
End If
PatchDownloader.DownloadFileAsync(Uri, SpeicherOrt)
Busy = True
Exit Do
End If
Loop
Next
File.Delete(AppPath & "\patchlist.xml")
Exit Do
End If
Catch ex As Exception
End Try
Loop
End Sub
Private Sub PatchDownloader_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles PatchDownloader.DownloadFileCompleted
Busy = False
If PB_GSM.Value = ANZAHLDLS Then
Else
PB_GSM.Value += 1
End If
End Sub
Private Sub PatchDownloader_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles PatchDownloader.DownloadProgressChanged
PB_AktuDatei.Maximum = e.TotalBytesToReceive
PB_AktuDatei.Value = e.BytesReceived
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oPro As New Process
With oPro
.StartInfo.UseShellExecute = True
.StartInfo.FileName = ".Quantum2 Starter.exe"
.Start()
End With
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Process.Start("http://quantum2.de/index.php")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Process.Start("http://quantum2.de/board/")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Process.Start("http://www.topliste.*****************/in/2887-quantum2-de.html")
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.Close()
End Sub
End Class
Noch zur Info: Der Code ist nur zum Teil von mir habe andere sachen noch bei google etc. gefunden.
Best regards.







