Register for your free account! | Forgot your password?

You last visited: Today at 17:48

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[VB] Problem

Discussion on [VB] Problem within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
Minato's Avatar
 
elite*gold: 34
Join Date: Jul 2011
Posts: 811
Received Thanks: 273
[VB] Problem

Hi Com,
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
Wäre super wenn mir da jemand weiter helfen könnte.
Noch zur Info: Der Code ist nur zum Teil von mir habe andere sachen noch bei google etc. gefunden.
Best regards.
Minato is offline  
Old 09/21/2014, 13:15   #2

 
snow's Avatar
 
elite*gold: 724
Join Date: Mar 2011
Posts: 10,479
Received Thanks: 3,318
Wenn du jetzt noch verrätst, wo dein Code nicht mehr funktioniert, kann dir sogar geholfen werden. So ist das ein Ratespiel.

#moved
snow is offline  
Thanks
1 User
Old 09/21/2014, 15:52   #3
 
Minato's Avatar
 
elite*gold: 34
Join Date: Jul 2011
Posts: 811
Received Thanks: 273
Also der Patcher lädt ja eine patchlist.xml runter von meinem angegebenen Pfad.
In dieser patchlist.xml ist folgender inhalt:
Sobald er bei einer Datei im Verzeichnis pack\ ankommt lädt er nicht weiter.
Und auch sonst ist komisch dass die Daten 0Kb gross sind, weis nicht ob diese erst zugänglich sind wenn der Patcher fertig ist ^^

Update: jetzt hat er was ausgespuckt beim Debuggen:

best regards.
Minato is offline  
Old 09/21/2014, 17:55   #4
 
tolio's Avatar
 
elite*gold: 2932
The Black Market: 169/1/0
Join Date: Oct 2009
Posts: 6,966
Received Thanks: 1,097
Ausm thread kannst steuerelemente nicht verändern, musst invoken um den thread zu überwinden, zb so
Code:
Me.Invoke(Sub() 
lbl.text = "text"
)
msdn.microsoft.com/en-us/library/system.windows.forms.control.invoke(v=vs.110).aspx
tolio is offline  
Reply


Similar Threads Similar Threads
[Problem]Habe ein Problem und zwar spinnt mein VPC etwas(ohne Grund)?!
07/28/2011 - Metin2 Private Server - 10 Replies
Also wie schon gesagt meins Server spinnt wodurch kiks usw. kommen :( ich lade euch die Screens in den Anhang, mit der Hoffnung, dass ihr mir helfen könnt :) wäre echt sehr nice :)



All times are GMT +2. The time now is 17:48.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.