VB.NET - 检查并执行更新?

时间:2016-04-17 17:02:47

标签: vb.net visual-studio visual-studio-2015

所以我有一小部分VB.NET可以检查是否有更新。 但是有几个问题:

它可以在不停止执行主代码的情况下执行此操作;

它甚至不会下载文件;

我无法关闭找到更新/下载更新然后打开新文件的应用。

我怎样才能让它完成所有这些?

当前代码:

Public Sub CheckForUpdates()

        'Connect to the Version File and Open It/Read It's Contents;
        Dim request As HttpWebRequest = WebRequest.Create("https://dl.dropboxusercontent.com/s/rrk7yhfjvy500jl/version.txt")
        Dim response As HttpWebResponse = request.GetResponse()
        Dim sr As StreamReader = New StreamReader(response.GetResponseStream())

        'Set the Variables to the Appropriate Versions;
        Dim newestversion As String = sr.ReadToEnd()
        Dim currentversion As String = Application.ProductVersion

        'If the program isn't up to date;
        If Not newestversion.Contains(currentversion) Then

            MessageBox.Show("Downloading update!")

            'Download the Update;
            Using wc = New WebClient()

                'Download the newest EXE file and store it in the same Directory as the Current EXE file;
                wc.DownloadFile("https://dl.dropboxusercontent.com/s/da3in67jjayvqsz/PRAGMA1.exe", Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "PRAGMA1.exe"))

            End Using

        End If

    End Sub

(它不起作用)

0 个答案:

没有答案