-
Sep 16th, 2014, 11:47 AM
#1
Thread Starter
Hyperactive Member
Version Check
Something I came up with just now, I think some may find useful.
Basically place this in your program form load and if you want a button.
Checks local assembly version, checks a text file on server which holds the latest version. You can expand on this with a Yes/No or update button where the program closes and it runs the latest version setup.
vb Code:
Shared Sub VersionCheck() Try Dim MyProgramVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString Dim serverVersionFile As String = textfile-that-holds-version-on-server.txt ' Dim reader As New System.IO.StreamReader(serverVersionFile, Encoding.Default) Dim VersionFromFile ' Do While Not reader.EndOfStream VersionFromFile = reader.ReadLine Loop reader.Close() ' Dim currentVersion As New Version(MyProgramVersion) Dim serverVersion As New Version(VersionFromFile) ' 'Update somewhere in program labels for current and server version MainWindow.OptionsLabelCurrentVersionResult.Text = currentVersion.ToString MainWindow.OptionsLabelServerVersionResult.Text = serverVersion.ToString 'Throw messagebox with result If Version.op_GreaterThan(serverVersion, currentVersion) Then MessageBox.Show("Current Version: " & MyProgramVersion & vbNewLine & "Server Version: " & serverVersion.ToString & vbNewLine & vbNewLine & "Please update to the latest version.", AppTitle) End If Catch ex As Exception MessageBox.Show(ex.Message, AppTitle) End Try End Sub
-
Sep 17th, 2014, 10:57 AM
#2
Junior Member
Re: Version Check
Good Idea but...if someone changes the assembly version?
-
Sep 17th, 2014, 11:35 AM
#3
Thread Starter
Hyperactive Member
Re: Version Check
The assembly version is changed by you as the owner of the program so is the text file on the server. I'm the sole developer on the app right now, so I found this a handy means to notify the user of an update. Every-time I'm about to release I update both.
-
Sep 17th, 2014, 11:39 AM
#4
Junior Member
Re: Version Check
Originally Posted by a_ahmed
The assembly version is changed by you as the owner of the program so is the text file on the server. I'm the sole developer on the app right now, so I found this a handy means to notify the user of an update. Every-time I'm about to release I update both.
Anyone can change the assembly version using any Hex Editor (as HxD) or Resource Editor (as ResHack).
I think the best way to do this is using a variable and obfuscate the code.
-
Sep 17th, 2014, 12:23 PM
#5
Thread Starter
Hyperactive Member
Re: Version Check
That is true, but why would anyone be editing the assembly version using a hex editor? I can understand someone could do that but it's beyond the scope of this simply because it's meant to be used a by user to be notified there is a new version to update
You are right though, alternatively you could set a variable!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|