Hey, I made A updater/unziper For my Minecraft world, becuse me and a friend switch back and forward, and my problem is that the download stops at 15%
The zip File size is : 54,6 MB
Code
Code:
Imports System.Net
Imports ComponentAce.Compression.Archiver
Imports ComponentAce.Compression.ZipForge
Imports ComponentAce.Compression.ZipForgeRealTime
Public Class Form1
Private WithEvents httpclient As WebClient
Private Sub AutoUpdate()
'this gets the directory where the main program is in no mather where it is on the computer
'whether it is in the root of C:\ or on the userīs desktop. This will also prepare itself
'by assigning the progressbar certain values and it will also tell the user where the setup
'file is going.
httpclient = New WebClient
Label1.Text = "Preparing To Download Installation Files..."
Dim directory As String = Application.StartupPath & "\Release.zip"
Label3.Text = "https://fake.com/Minecraft%20Server%201.8.1/Release.zip"
Label4.Text = directory
ProgressBar1.Value = 0
ProgressBar1.Maximum = 100
Try
'Since the code below isnīt very compatible with variables, you now see why the code above
'has been put there for a reason. this code is where it downloads the setup files (.zip) and
'stored it into the main root of the software so it is ready for installation.
Label1.Text = "updater Status: Downloading Setup Files..."
httpclient.DownloadFileAsync(New Uri(Label3.Text), Label4.Text)
Catch ex As Exception
'of course there would be internert problems whitch is why there is a try/catch code been put
'into place. This little line below will tell the user that something has happened during the download.
Label1.Text = "Updater Status: Download Failed! Either your connection died or the setup files are no longer available"
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button3.Enabled = False
Label1.Text = "Updater Status: Update Ready"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AutoUpdate()
Button1.Enabled = False
Button2.Enabled = False
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Button3.Enabled = False
Try
Label1.Text = "Updater Status: Now Installing..."
Dim archiver As New ZipForge()
' The name of the ZIP file to unzip
archiver.FileName = Application.StartupPath & "\Release.zip"
' Open an existing archive
archiver.OpenArchive(System.IO.FileMode.Open)
' Default path for all operations
archiver.BaseDir = Application.StartupPath
' Extract all files from the archive to C:\Temp folder
archiver.ExtractFiles("*.*")
' Close archive
archiver.CloseArchive()
Label1.Text = "Updater Status: Installation Completed! MinecraftServer is now updated"
Button2.Enabled = True
Catch ex As Exception
Label1.Text = "Updater Status: Installation Failed! There Maybe a Problem with the setup files"
Button1.Enabled = True
Button2.Enabled = True
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Process.Start("Propriedades.txt")
Me.Close()
Catch ex As Exception
If MsgBox("The Propriedades.txt file seems to be missing, This my require a full re-install Of the McServer. Would you like the updater to (re)download the setup files?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
'When clicked, this will tell the hand made private sub to start it's work but also all buttons
'will be disabled disabled during the operation.
AutoUpdate()
Button1.Enabled = False
Button2.Enabled = False
Else
MsgBox("If Thats The case, You will be required to do a full re-install of the software. The updater will now close", MsgBoxStyle.Information)
Me.Close()
End If
End Try
End Sub
Private Sub httpclient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles httpclient.DownloadProgressChanged
ProgressBar1.Maximum = e.TotalBytesToReceive
ProgressBar1.Value = e.BytesReceived
Label2.Text = e.ProgressPercentage & "%"
Dim MB As Single
Dim MB2 As Single
Dim KB As Single
Dim Kb2 As Single
MB = ((e.BytesReceived / 1024) / 1024)
MB2 = ((e.TotalBytesToReceive / 1024) / 1024)
KB = (e.BytesReceived / 1024)
Kb2 = (e.TotalBytesToReceive / 1024)
If KB And Kb2 <= 1024 Then
Label5.Text = "Download @ " & e.ProgressPercentage & "% / " & KB.ToString("N2") & "KB out of " & Kb2.ToString("N2") & "KB"
ElseIf KB <= 1024 And Kb2 >= 1024 Then
Label5.Text = "Download @ " & e.ProgressPercentage & "% / " & KB.ToString("N2") & "KB out of " & MB2.ToString("N2") & "MB"
ElseIf KB And Kb2 >= 1024 Then
Label5.Text = "Download @ " & e.ProgressPercentage & "% / " & MB.ToString("N2") & "MB out of " & MB2.ToString("N2") & "MB"
End If
If Label2.Text = "100%" Then
Button3.Enabled = True
Label1.Text = "Updater Status: Download Completed! Ready For Installation..."
End If
End Sub
End Class
If some one can help I would appreciate.