Robs Programming Junk
Welcome to my programming blog!With some luck you will find some tasty nuggets of information here. If you do find something please post a comment on where or how you used it. I like to see what sort of impact my work has on others.
Wednesday, November 29, 2006
Version Checking Class for PAD files.
Last Night I wrote what I thougt was some really brilliant code for checking a PAD file for the proper version. For my software I keep a pad file online which allows me to simply upload the PAD file for my software to another site. It also allows me to use the same file to check the version in my software. Here is the class that I use to do this. Calling it is really simple, just invoke the method with the current version and the URL to the pad file. If there is no internet access or an error, it returns that there is no update available.
Imports System.io
Imports System.Net
Imports System.Text
Imports System.Xml
Imports System.Xml.XmlDocument
Public Class clsCheckVersion
Private strListedVersion As String
Private strDownloadURL As String
Private strApplicationInfoURL As String
Public ReadOnly Property ListedVersion() As String
Get
Return strListedVersion
End Get
End Property
Public ReadOnly Property PrimaryDownloadURL() As String
Get
Return strDownloadURL
End Get
End Property
Public ReadOnly Property ApplicationInfoURL() As String
Get
Return strApplicationInfoURL
End Get
End Property
Public Function CheckVersion(ByVal strCurrentVersion As String, ByVal strPadFile As String) As Boolean
Try
Dim xmlPad As New Xml.XmlDocument
Dim xmlNode As XmlNode
Dim strXMLFileName As String
strXMLFileName = GetURL(strPadFile)
xmlPad.Load(strXMLFileName)
' Primary Download URL (not required)
Try
xmlNode = xmlPad.SelectSingleNode("/XML_DIZ_INFO/Web_Info/Download_URLs/Primary_Download_URL")
strDownloadURL = xmlNode.InnerText
Catch ex As Exception
strDownloadURL = ""
End Try
' Primary Application info URL (Not Required)
Try
xmlNode = xmlPad.SelectSingleNode("/XML_DIZ_INFO/Web_Info/Application_URLs/Application_Info_URL")
strApplicationInfoURL = xmlNode.InnerText
Catch ex As Exception
strApplicationInfoURL = ""
End Try
' Required Program version, if not present, exception fired and returns false (no new version information available)
xmlNode = xmlPad.SelectSingleNode("/XML_DIZ_INFO/Program_Info/Program_Version")
' Compare Version length based on dest this is in case build information is not
' included in the version in the pad file.
strListedVersion = xmlNode.InnerText.Trim()
If strCurrentVersion.StartsWith(xmlNode.InnerText.Trim()) Then
CheckVersion = False
Else
CheckVersion = True
End If
xmlPad = Nothing
System.IO.File.Delete(strXMLFileName)
Catch ex As Exception
Debug.WriteLine(ex.ToString)
CheckVersion = False
End Try
End Function
Public Function GetURL(ByVal destURL As String) As String
Dim oWebReq As HttpWebRequest = CType(WebRequest.Create(destURL), HttpWebRequest)
Dim oWebResp As HttpWebResponse = CType(oWebReq.GetResponse(), HttpWebResponse)
Dim oStream As Stream = oWebResp.GetResponseStream()
Dim objXMLStream As StreamWriter
GetURL = System.IO.Path.GetTempFileName
Debug.WriteLine(GetURL)
objXMLStream = System.IO.File.CreateText(GetURL)
Dim iByte As Integer
iByte = oStream.ReadByte
While iByte <> -1
objXMLStream.Write(Chr(iByte))
iByte = oStream.ReadByte
End While
objXMLStream.Close()
End Function
End Class
View my portfolio at iFreelance.com
Hire MechSoftware for Quality Assurance (QA), Database Programming, and Security Design/Programming
Find QA Freelance Jobs at iFreelance.com
Hire MechSoftware for Quality Assurance (QA), Database Programming, and Security Design/Programming
Find QA Freelance Jobs at iFreelance.com
Recent Posts
Quick Test Case
PhotoCopy
Blinky
HARDWARE: Creating My own PVR for HDTV (ATSC) on a...
VFP: User interface not allowed at this time
VFP: Inserting Nodes with XML Object
Linux: Dell Latitude LM, XWindows, Neomagic Magicg...
CIO Blogs - Could "Found Code" Cripple Your Compan...
Links for .NET security info
TechToolBlog 195 Free Online Programming Books
Archives
01/01/2005 - 02/01/200502/01/2006 - 03/01/2006
03/01/2006 - 04/01/2006
04/01/2006 - 05/01/2006
05/01/2006 - 06/01/2006
09/01/2006 - 10/01/2006
10/01/2006 - 11/01/2006
11/01/2006 - 12/01/2006
12/01/2006 - 01/01/2007
04/01/2007 - 05/01/2007
05/01/2007 - 06/01/2007
01/01/2008 - 02/01/2008
02/01/2008 - 03/01/2008
05/01/2008 - 06/01/2008
06/01/2008 - 07/01/2008
08/01/2008 - 09/01/2008
09/01/2008 - 10/01/2008
11/01/2008 - 12/01/2008
12/01/2008 - 01/01/2009
01/01/2009 - 02/01/2009
02/01/2009 - 03/01/2009
04/01/2009 - 05/01/2009
05/01/2009 - 06/01/2009
07/01/2009 - 08/01/2009
01/01/2010 - 02/01/2010
My Software
Blinky - GBPVR PluginPhotoCopy - GBPVR Plugin
QTC - Quick Test Case
rBoop - Rob's Timers
Programming Links
C# FormatterNSIS
Other Links
Damn Small LinuxSites I Manage
Do it yourself SEO. Cheap.Pet Supplies
Dog toy of the month club
SqueakerZ pet Deals
Geocaching Community
Hitch hiker Tracking
