如果软件已经打开,则更新软件功能不起作用

时间:2015-03-14 13:48:54

标签: vb.net

我有一个检查应用程序更新的函数。我有两个执行此功能的模式,第一次是应用程序的启动和工具提示菜单。如果我第一次执行该软件所有工作正常,则发现更新,但如果我按下工具提示菜单中的按钮,则相同的功能(确切的功能)不起作用。特别是发现了更新,但是用于下载它的软件(无限蓝色)没有启动。 这是功能:

Dim MyAppName As String = "Sund.exe"
        Dim url As String = "www.site.com/update/" & "FileUpdates371.php"
        Dim pageRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
        Dim pageResponse As WebResponse = pageRequest.GetResponse()
        Dim filelist As String : Dim Mainlist As String
        Using r As New StreamReader(pageResponse.GetResponseStream())
            filelist = r.ReadToEnd
            If Not IO.File.Exists(Application.StartupPath & "\" & "Updates") Then
                IO.File.WriteAllText(Application.StartupPath & "\" & "Updates", filelist)
            End If
            Dim sr As New StreamReader(Application.StartupPath & "\" & "Updates")
            Mainlist = sr.ReadToEnd
            Dim FileLines() As String = filelist.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
            Dim MainLines() As String = Mainlist.Split(New String() {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
            If Not Mainlist = filelist And Not FileLines.Length < MainLines.Length Then
                Dim answer As DialogResult
                answer = MessageBox.Show("Update available", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                If answer = vbYes Then
                    Dim App As New Process
                    App.StartInfo.FileName = Application.StartupPath & "\" & "InfinityBlue.exe"
                    App.StartInfo.Arguments = "Update|" & MyAppName & "|" & url
                    App.Start()
                    Me.Close()
                End If
            End If
        End Using
        If My.Computer.FileSystem.FileExists(Application.StartupPath & "\" & "InfinityBlueUpdate.exe") Then
            My.Computer.FileSystem.DeleteFile(Application.StartupPath & "\" & "InfinityBlue.exe", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
            My.Computer.FileSystem.RenameFile(Application.StartupPath & "\" & "InfinityBlueUpdate.exe", "InfinityBlue.exe")
        End If

我也试图捕获异常并且没有例外。为什么会这样?

0 个答案:

没有答案