Mon code pour qui sa peut aider:
Imports System.Net
Imports System.IO
Private Sub NewUpdateHtml()
Try
If My.Computer.Network.IsAvailable Then
Dim Link As String = "http://www.votreSite.com/Execution/" & My.Application.Info.Title & "/version.html"
Dim wRequest As WebRequest = WebRequest.Create(Link)
Dim wResult As WebResponse = wRequest.GetResponse()
Dim sReader As New StreamReader(wResult.GetResponseStream())
Dim SourceCode As String = sReader.ReadToEnd()
sReader.Close()
wResult.Close()
SourceCode = Split(SourceCode, "")(1)
SourceCode = Split(SourceCode, "
")(0)
If (SourceCode.Replace(" o", "") = My.Application.Info.Version.ToString) Then
MsgBox("You have the latest version of the software.", MsgBoxStyle.Information, "AutoUpdate")
Else
Dim msgx As Object = MsgBox("An update is available, do you want to dowload ?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "Auto Update")
If msgx = vbYes Then
'System.Diagnostics.Process.Start("http://www.votreSite.com/Execution/" & My.Application.Info.Title & "/" & SourceCode.Replace(" o", "") & "/" & My.Application.Info.Title & ".exe")
If Not File.Exists(Application.ExecutablePath & "-Old.exe") Then
File.Move(Application.ExecutablePath, Application.ExecutablePath & "-Old.exe")
Else
File.Delete(Application.ExecutablePath & "-Old.exe")
System.Threading.Thread.Sleep(500)
File.Move(Application.ExecutablePath, Application.ExecutablePath & "-Old.exe")
End If
System.Threading.Thread.Sleep(500)
If Not File.Exists(My.Application.Info.DirectoryPath & "" & My.Application.Info.Title & ".exe") Then
My.Computer.Network.DownloadFile("http://www.votreSite.com/Execution/" & My.Application.Info.Title & "/" & SourceCode.Replace(" o", "") & "/" & My.Application.Info.Title & ".exe", My.Application.Info.DirectoryPath & "" & My.Application.Info.Title & ".exe")
Else
File.Delete(My.Application.Info.DirectoryPath & "" & My.Application.Info.Title & ".exe")
System.Threading.Thread.Sleep(500)
My.Computer.Network.DownloadFile("http://www.votreSite.com/Execution/" & My.Application.Info.Title & "/" & SourceCode.Replace(" o", "") & "/" & My.Application.Info.Title & ".exe", My.Application.Info.DirectoryPath & "" & My.Application.Info.Title & ".exe")
End If
AppendText(Environ("tmp") & "\update.bat", ":Repeat " & vbCrLf & "del '" & Application.ExecutablePath & "-Old.exe" & vbCrLf & "' if exist '" & Application.ExecutablePath & "-Old.exe" & "' goto Repeat" & vbCrLf & "del '" & Environ("tmp") & "\update.bat'")
Shell(Environ("tmp") & "\update.bat", AppWinStyle.Hide)
Shell(My.Application.Info.DirectoryPath & "" & My.Application.Info.Title & ".exe", AppWinStyle.NormalFocus, False)
MsgBox("Updated Sucessfully", MsgBoxStyle.Information, "AutoUpdate")
Application.Exit()
Else
If SourceCode.Contains(" o") Then End
End If
End If
End If
Catch ex As Exception
MsgBox("Error come, Details:" & vbCrLf & ex.Message.ToString, MsgBoxStyle.Exclamation, "AutoUpdate")
Application.Exit()
End Try
End Sub
Public Sub AppendText(ByVal vsFilePath As String, ByVal vsText As String)
With New System.IO.StreamWriter(vsFilePath, True)
.WriteLine(vsText)
.Close()
End With
End Sub