Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Net
- Imports Ionic.Zip
- Public Class Form1
- Dim ver As String
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim client As WebClient = New WebClient()
- Dim localver
- ver = client.DownloadString("http://skymoders.pl/api/verlauncher.txt")
- If My.Computer.FileSystem.FileExists("C:\skymoders\launcher\verl.txt") Then
- Dim sr As StreamReader = New StreamReader("C:\skymoders\launcher\verl.txt")
- localver = sr.ReadToEnd
- End If
- Dim client1 As WebClient = New WebClient()
- AddHandler client1.DownloadProgressChanged, AddressOf client1_ProgressChanged
- AddHandler client1.DownloadFileCompleted, AddressOf client1_DownloadCompleted
- If localver = ver Then
- Process.Start("C:\skymoders\launcher\SkyModers.exe")
- Me.Close()
- Else
- My.Computer.FileSystem.CreateDirectory("C:\skymoders\launcher")
- Try
- client1.DownloadFileTaskAsync(New Uri("http://skymoders.pl/api/Launcher.zip"), "C:\skymoders\launcher.zip")
- Catch
- MsgBox("Błąd połączenia, sprawdz połączenie internetowe")
- End Try
- End If
- End Sub
- Private Sub client1_ProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs)
- Dim bytesIn As Double = Double.Parse(e.BytesReceived.ToString())
- Dim totalBytes As Double = Double.Parse(e.TotalBytesToReceive.ToString())
- Dim percentage As Double = bytesIn / totalBytes * 100
- ProgressBar1.Value = Int32.Parse(Math.Truncate(percentage).ToString())
- End Sub
- Private Sub client1_DownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
- Try
- Console.WriteLine("C:\skymoders\launcher.zip")
- Dim MCLibFile = "C:\skymoders\launcher.zip"
- Dim ZipToUnpack As String = MCLibFile
- Dim UnpackDirectory As String = "C:\skymoders\launcher"
- Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
- Dim eb As ZipEntry
- ' here, we extract every entry, but we could extract conditionally,
- ' based on entry name, size, date, checkbox status, etc.
- For Each eb In zip1
- eb.Extract(UnpackDirectory, ExtractExistingFileAction.OverwriteSilently)
- Next
- End Using
- Catch
- End Try
- File.WriteAllText("C:\skymoders\launcher\verl.txt", ver)
- Process.Start("C:\skymoders\launcher\SkyModers.exe")
- Me.Close()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment