Datei wird heruntergeladen aber ist nicht am Speicher Ort

  • VB.NET

Es gibt 9 Antworten in diesem Thema. Der letzte Beitrag () ist von MVN050.

    Datei wird heruntergeladen aber ist nicht am Speicher Ort

    Hallo,
    Ich programmiere einen Launcher für mein Spiel.
    Wenn man auf Update klickt lädt er das Spiel herunter und soll es in der Appdata in dem Spiele Ordner speichern. Der Fortschritt wird in einer Progress Bar angezeigt aber nach dem Download kommt 1. nicht die MsgBox "Update erfolgreich" und 2. Die Datei ist nicht im Ordner wo sie eigentlich sein sollte.
    kann mir einer bitte helfen?
    Quelltext der Launcher Form:

    VB.NET-Quellcode

    1. Public Class Form1
    2. Private WithEvents downloader As Net.WebClient
    3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    4. Dim Pfad As String
    5. Pfad = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
    6. Process.Start(Pfad + "\SpielOrdner\SpielName\main.exe")
    7. Me.Close()
    8. End Sub
    9. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    10. PictureBox2.Parent = Me
    11. PictureBox2.BackColor = Color.Transparent
    12. End Sub
    13. Private Sub PictureBox2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
    14. Application.Exit()
    15. End Sub
    16. Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
    17. Me.WindowState = FormWindowState.Minimized
    18. End Sub
    19. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    20. Form2.Show()
    21. Me.Enabled = False
    22. End Sub
    23. End Class


    Quelltext der Updater Form:

    VB.NET-Quellcode

    1. Imports Ionic.Zip
    2. Imports System.Net
    3. Public Class Form2
    4. Private WithEvents httpclient As WebClient
    5. Dim Pfad As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
    6. Private Sub Form2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
    7. Form1.Enabled = True
    8. End Sub
    9. Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    10. Try
    11. Dim Pfad As String = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
    12. Dim EndPfad As String = Pfad + "/Spielname/Update/"
    13. httpclient = New WebClient
    14. Dim URL As String = "http://Die Seite zum download"
    15. httpclient.DownloadDataAsync(New Uri(URL), "EndPfad")
    16. Catch ex As Exception
    17. MsgBox("Fehler bein Update! Kontkatieren sie Mich über diesen Fehler.", MsgBoxStyle.Critical, "Fehler")
    18. Me.Close()
    19. End Try
    20. End Sub
    21. Private Sub Installieren_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Installieren.Click
    22. Using zip As ZipFile = ZipFile.Read(Pfad + "/Spielname/Update/Update.zip")
    23. Dim Entry As ZipEntry
    24. For Each Entry In zip
    25. Entry.Extract(Pfad + "/Spielname/SpielOrdner/", ExtractExistingFileAction.OverwriteSilently)
    26. Next
    27. End Using
    28. End Sub
    29. Private Sub httpclient_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles httpclient.DownloadFileCompleted
    30. MsgBox("Update Erfolgreich!", MsgBoxStyle.Information, "Erfolgreich!")
    31. End Sub
    32. Private Sub httpclient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles httpclient.DownloadProgressChanged
    33. Me.ProgressBar1.Value = e.ProgressPercentage
    34. Dim totalBites As Double = e.TotalBytesToReceive / 1024
    35. Dim bytes As Double = e.BytesReceived / 1024
    36. Me.Label1.Text = bytes & " KB von " & totalBites & " KB"
    37. End Sub
    38. End Class
    du hast da ein kleiner denkfehler drinne :D aber bist nicht der einzigste der das hat
    der code hier Environment.GetFolderPath(Environment.SpecialFolder.ApplicationDatamacht für jeden neuen ordner das zeichen hier "\" du benutzt aber manual das zeichen hier "/"
    somit sieht dein pfad dan irgentwie so aus
    c:\programme\programm/gamename/main.exe
    das er den pfad nicht finden kann ist klar :D

    benutz einfach das hier
    System.IO.Directory.GetCurrentDirectory.ToString.Replace("\", "/")
    bzw so
    pfat=Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData.ToString.Replace("\", "/")
    Die Path-Klasse befindet sich im System.IO-Namespace. Also Namespace importieren oder den kompletten Pfad der Klasse hinschreiben.
    Die Unendlichkeit ist weit. Vor allem gegen Ende. ?(
    Manche Menschen sind gar nicht dumm. Sie haben nur Pech beim Denken. 8o