【发布时间】:2014-05-08 15:15:06
【问题描述】:
这是我用来检查更新然后启动更新文件的代码。基本上我用在线文本检查文件版本,看看哪个更大。
Dim wc As New WebClient()
Dim upt As Double = Double.Parse(wc.DownloadString("someurl/update.txt"))
Dim Info As FileVersionInfo
Info = FileVersionInfo.GetVersionInfo(Application.StartupPath & "\app.exe")
Dim curr As Double = Double.Parse(Info.FileVersion.Split(".")(0) & "." & Info.FileVersion.Split(".")(1) & Info.FileVersion.Split(".")(2))
If (upt > curr) Then
If (MessageBox.Show("Please Update app !!!", "Update Available", MessageBoxButtons.OK, MessageBoxIcon.Question) = Windows.Forms.DialogResult.OK) Then
Dim ui As New updateinfo
ui.RichTextBox1.Text = wc.DownloadString("someurl")
ui.ShowDialog()
Process.Start(Application.StartupPath & "\update.exe")
Application.Exit()
Else
Application.Exit()
End If
End If
问题出在非英语操作系统上,它给了我诸如“输入字符串格式不正确”之类的错误。如何解决?不幸的是,我无法访问任何其他语言的操作系统,并且想深入了解它。
还有其他任何检查更新的方法都很好 - 我不能使用 clickonce
【问题讨论】:
-
当您拥有像 FileMajorPart 等随时可用的属性时,使用字符串解析几乎没有意义。帮助您避免在其他文化中使用数字格式,而不是每个人都使用句号。