Reply to thread

The user clicks on a menuitem then this code executes:


[code]


     <summary>

     Gets the update information.

     </summary>

     <remarks></remarks>

    Friend Sub GetUpdate()


        If My.Computer.FileSystem.FileExists(MainForm.Path & "newVersion.txt") Then

            My.Computer.FileSystem.DeleteFile(MainForm.Path & "newVersion.txt")

        End If


        Dim baseUri As New Uri("http://www.blisspointranch.com/")

        Dim basePath As New Uri(baseUri, "programs/charactersheet/")

        Dim filePath As New Uri(basePath, "version.txt")


        Disable menu item.

        MainForm.menuitemUpdate.Text = "Checking for Updates..."

        MainForm.menuitemUpdate.Enabled = False


        Try to download file. If cant: Display returned server error, re-enable menus, exit subroutine.

        Try

            MainForm.webclient.DownloadFileAsync(filePath, MainForm.Path & "newVersion.txt")

        Catch ex As UriFormatException

            MessageBox.Show("Could not check for new version, server reported an error: " & vbCrLf & _

                                       ex.Message & vbCrLf & _

                                       "If this problem persists contact the program vender for support.", _

                                       My.Application.Info.Title, _

                                       MessageBoxButtons.OK, _

                                       MessageBoxIcon.Error)

        Catch ex As WebException

            MessageBox.Show("Could not check for new version, server reported an error: " & vbCrLf & _

                                      ex.Message & vbCrLf & _

                                      "If this problem persists contact the program vender for support.", _

                                       My.Application.Info.Title, _

                                       MessageBoxButtons.OK, _

                                       MessageBoxIcon.Error)

        Catch ex As InvalidOperationException

            MessageBox.Show("Could not check for new version, server reported an error: " & vbCrLf & _

                                      ex.Message & vbCrLf & _

                                     "If this problem persists contact the program vender for support.", _

                                     My.Application.Info.Title, _

                                     MessageBoxButtons.OK, _

                                     MessageBoxIcon.Error)

        Finally

            MainForm.menuitemUpdate.Text = "Check for Updates..."

            MainForm.menuitemUpdate.Enabled = True

        End Try


    End Sub


[/code]


Back
Top