TonyVk

Untitled

Jun 5th, 2016
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Net
  3. Imports System.Text
  4. Imports System.Security
  5. Class Web_update
  6. Dim version As String
  7. Public Shared Sub Main()
  8. Dim URI As String
  9. Dim Client As New Net.WebClient()
  10. '
  11. 'REPLACE Program WITH YOUR APPLICATIONS NAME.
  12. '
  13. 'REMEMBER TO EDIT FILEVERSION IN ASSEMBLY INFORMATION
  14. '
  15. '
  16. 'Edit URI to your version.html-file.
  17. URI = "http://sikora-agar.comlu.com/cod4/h2ov2/version.html"
  18. 'Edit URI to your programs zip-file
  19.  
  20. Dim wr As HttpWebRequest = CType(WebRequest.Create(URI.ToString), HttpWebRequest)
  21. Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
  22. Dim str As Stream = ws.GetResponseStream()
  23. Dim inBuf(100000) As Byte
  24. Dim bytesToRead As Integer = CInt(inBuf.Length)
  25. Dim bytesRead As Integer = 0
  26. Dim sr As StreamReader = New System.IO.StreamReader("version.txt")
  27. Dim versiona As Integer = CInt(sr.ReadToEnd.Replace(".", "").Substring(0, 4))
  28. sr.Close()
  29. While bytesToRead > 0
  30. Dim n As Integer = str.Read(inBuf, bytesRead, bytesToRead)
  31. If n = 0 Then
  32. Exit While
  33. End If
  34. bytesRead += n
  35. bytesToRead -= n
  36. End While
  37. Dim fstr As New FileStream("version.txt", FileMode.OpenOrCreate, FileAccess.Write)
  38. fstr.Write(inBuf, 0, bytesRead)
  39. str.Close()
  40. fstr.Close()
  41. Dim sranje As StreamReader = New System.IO.StreamReader("version.txt")
  42. Dim version As Integer = CInt(sranje.ReadToEnd.Replace(".", "").Substring(0, 4))
  43. sr.Close()
  44. If versiona < version Then
  45. Client.DownloadFile(Web_update.Downuri, My.Computer.FileSystem.SpecialDirectories.Temp.ToString & "\Program_Update.zip", "", "", True, 300000, True)
  46. Process.Start(My.Computer.FileSystem.SpecialDirectories.Temp.ToString & "\Program_Update.zip")
  47. Application.Exit()
  48. End If
  49. End Sub 'Main
  50. End Class 'Web_update
Advertisement
Add Comment
Please, Sign In to add comment