我的VB应用程序的自动更新程序

时间:2014-05-02 11:43:29

标签: vb.net

我的自动更新程序出了问题。它不断告诉我的客户有可用的更新并为他们下载,即使他们已经在使用最新版本。在VB中,我的程序集是1.0.0.0,在我的newversion.txt dropbox链接中,版本也是1.0.0.0 - 所以两者完全匹配。我试着自己编写代码,这是同样的问题,所以我尝试了一个开源...仍然是同样的问题。这就是我所拥有的;

Public Class Form3

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    CheckForUpdates()
End Sub

Public Sub CheckForUpdates()

    Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://www.dropbox.com/s/t2m4s9umxq0i471/newestversion.txt")
    Dim response As System.Net.HttpWebResponse = request.GetResponse()

    Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

    Dim newestversion As String = sr.ReadToEnd()
    Dim currentversion As String = Application.ProductVersion

    If newestversion.Contains(currentversion) Then
        Button1.Text = ("No new updates")
        Button1.Enabled = False

    Else

        Button1.Text = ("An update is available")
        Button1.Enabled = True
        System.Diagnostics.Process.Start("https://www.dropbox.com/s/5qcp8qxv7icexij/Twitch%20Suite-HF.exe")

    End If
End Sub

结束班

编辑:代码完全正确!这是我的错,使用其他人不使用dropbox。感谢。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题!答案很简单:) 您对newestversion.txt的原始下载链接是https://www.dropbox.com/s/t2m4s9umxq0i471/newestversion.txt因此链接必须是直接链接,因为更新程序无法正确查找更新。所以要修复问题,只需在下载链接的末尾添加?dl = 1,当你在末尾添加?dl = 1时,链接就是https://www.dropbox.com/s/t2m4s9umxq0i471/newestversion.txt?dl=1 Cogratulations!编辑下载链接时,您现在具有正确的更新程序功能!

相关问题