Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.IO
- Imports System.Net
- Imports System.Text
- Imports System.Security
- Class Web_update
- Dim version As String
- Public Shared Sub Main()
- Dim URI As String
- Dim Client As New Net.WebClient()
- '
- 'REPLACE Program WITH YOUR APPLICATIONS NAME.
- '
- 'REMEMBER TO EDIT FILEVERSION IN ASSEMBLY INFORMATION
- '
- '
- 'Edit URI to your version.html-file.
- URI = "http://sikora-agar.comlu.com/cod4/h2ov2/version.html"
- 'Edit URI to your programs zip-file
- Dim wr As HttpWebRequest = CType(WebRequest.Create(URI.ToString), HttpWebRequest)
- Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
- Dim str As Stream = ws.GetResponseStream()
- Dim inBuf(100000) As Byte
- Dim bytesToRead As Integer = CInt(inBuf.Length)
- Dim bytesRead As Integer = 0
- Dim sr As StreamReader = New System.IO.StreamReader("version.txt")
- Dim versiona As Integer = CInt(sr.ReadToEnd.Replace(".", "").Substring(0, 4))
- sr.Close()
- While bytesToRead > 0
- Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)
- If n = 0 Then
- Exit While
- End If
- bytesRead += n
- bytesToRead -= n
- End While
- Dim fstr As New FileStream("version.txt", FileMode.OpenOrCreate, FileAccess.Write)
- fstr.Write(inBuf, 0, bytesRead)
- str.Close()
- fstr.Close()
- Dim sranje As StreamReader = New System.IO.StreamReader("version.txt")
- Dim version As Integer = CInt(sranje.ReadToEnd.Replace(".", "").Substring(0, 4))
- sr.Close()
- If versiona < version Then
- Client.DownloadFile(Web_update.Downuri, My.Computer.FileSystem.SpecialDirectories.Temp.ToString & "\Program_Update.zip", "", "", True, 300000, True)
- Process.Start(My.Computer.FileSystem.SpecialDirectories.Temp.ToString & "\Program_Update.zip")
- Application.Exit()
- End If
- End Sub 'Main
- End Class 'Web_update
Advertisement
Add Comment
Please, Sign In to add comment