|
|||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionAs .NET Developer for implement a project that will check on some web server if there are update i use microsoft "ClickOnce". But because this application will be run on Windows locked i prefered to use the code to make the goal. BackgroundThe principal component of this project are:
The file Xml is structured on this way:
Every TAG update is a new version of program, the date of this version is attribute dtUpdate inside update node, so if version of program (that i match with key getSetting("FastBet", "Update", "LastUpdate") is old, the first thig that i do is to download file and metadata. The file of new version i found with attributes inside <file> node.
And Metadata is represented with node <config>.
Below we can see how this works! Using the codeIn the component update part I use the class Update. On this class there is a method that will get file xml and it will be loaded in XMLDoc property:
Function Main() Try Dim bytesProcessed As Integer = 0 Dim remoteStream As Stream = Nothing Dim localeStream As Stream = Nothing Dim response As HttpWebResponse = Nothing Dim request As HttpWebRequest = CType(WebRequest.Create(remoteFile), HttpWebRequest) response = request.GetResponse If Not response Is Nothing Then remoteStream = response.GetResponseStream localeStream = File.Create(LocaleFile) Dim buffer(1024) As Byte Dim Bytesread As Integer Do Bytesread = remoteStream.Read(buffer, 0, buffer.Length) localeStream.Write(buffer, 0, Bytesread) bytesProcessed += Bytesread If Bytesread = 0 Then Exit Do Loop If Not response Is Nothing Then response.Close() If Not remoteStream Is Nothing Then remoteStream.Close() If Not localeStream Is Nothing Then localeStream.Close() End If Return bytesProcessed End Function
|
||||||||||||||||||||||||||||||||||||||||