I have a problem here in my code.I want to delete the existing application exe in my downloadPath
and copy the new version of the application that is located in GetFilesFrom
then open the application again. But after the proc.Kill()
execute, the next line of code is not continue. Do I have a missing code?
Thank you.
Public CurExeVersion As String = Application.ProductVersion '1.0.1.0 version in my desktop app
Public version = FileVersionInfo.GetVersionInfo("\\Bdpc\inhouse apps\Admin Management\Application Files\Admin Management_1_0_0_0\Admin Management.exe")
Public ServerVersion As String = version.FileVersion '1.0.2.0 version in server
Dim client As New Net.WebClient
If CurExeVersion <> ServerVersion Then
If MessageBox.Show("Update is ready to install", "Do you want to continue?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Dim processName As String = "Admin Management"
Dim GetFilesFrom As String = "\\Bdpc\inhouse apps\Admin Management\Application Files\Admin Management_1_0_0_0\Admin Management.exe"
Dim downloadPath As String = "D:\Admin Management_1_0_0_0\Admin Management.exe"
If Process.GetProcessesByName(processName).Length > 0 Then
For Each proc As Process In Process.GetProcessesByName(processName)
proc.Kill()
Next
While Process.GetProcessesByName(processName).Length > 0
Threading.Thread.Sleep(100)
End While
End If
IO.File.Delete(downloadPath)
IO.File.Copy(GetFilesFrom, downloadPath)
Process.Start(downloadPath)
End If
End If