Hello,
I would like some help on this project that I am working on.
you may need to read this twice...
what I am trying to do is use vb.net application on my testing Windows SBS Server to read an xml file hosted on my business website in a testing folder.
The xml file may contain some data that I don’t want my clients users to read or copy.
I know I can just use a vb.net to download the xml file from the web then set the variables and things like that.
I would like some help on 2 things;
Vb.net code to read the xml file online without downloading it.
and xml encryption, for testing I don’t need this right now.
this is the code that I use to download the xml file and read It, just a simple updater.
#Region "Region_Updater1"
ublic urlfile As String = "http://localhost/sites/update/application/Update.xml"
Public XLocalLocation As String = Application.StartupPath & "\Update.xml"
Public xmlsettingslocation As String = Application.StartupPath & "\Settings.xml"
Public varFileExist As Boolean = False
#If 1 Then
Public Sub SubUpdate()
varFileExist = False
Dim url As New System.Uri(urlfile)
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(url)
Dim resp As System.Net.WebResponse = Nothing
Try
WriteLog("System: Update XML Path; " & urlfile, Color.RoyalBlue)
resp = req.GetResponse()
resp.Close()
req = Nothing
If System.IO.File.Exists(XLocalLocation) = True Then System.IO.File.Delete(XLocalLocation)
My.Computer.Network.DownloadFile(urlfile, XLocalLocation)
varFileExist = True
WriteLog("System: Connected To Update Server", Color.Green)
Catch ex As Exception
req = Nothing
varFileExist = False
WriteLog("System: Could Not Connect To Update Server, Path May Not Exist, Error: " & ex.Message, Color.Red)
End Try
WriteLog("System: Proceed With Download = " & varFileExist, Color.Orange)
If varFileExist = True Then
Dim fs As FileStream = Nothing : fs = New FileStream(Settings.XLocalLocation, FileMode.Open, FileAccess.Read)
Dim xmldoc As New XmlDataDocument() : xmldoc.Load(fs)
Dim xmlnode As XmlNodeList = Nothing : xmlnode = xmldoc.GetElementsByTagName("Update")
Dim XVersion As String = Nothing : XVersion = xmlnode(0).ChildNodes.Item(1).InnerText.Trim()
Dim XLocation As String = Nothing : XLocation = xmlnode(0).ChildNodes.Item(2).InnerText.Trim()
fs.Close()
If (LogSettings = 2) Or (LogSettings = 3) Then WriteLog("System: Update Version: " & XVersion, Color.RoyalBlue)
If (LogSettings = 2) Or (LogSettings = 3) Then WriteLog("System: Current Version: " & Application.ProductVersion, Color.RoyalBlue)
If (LogSettings = 2) Or (LogSettings = 3) Then WriteLog("System: Update Location: " & XLocation, Color.RoyalBlue)
If (LogSettings = 2) Or (LogSettings = 3) Then WriteLog("System: Update Local Location: " & Application.StartupPath & XLocalLocation, Color.RoyalBlue)
Try
WriteLog("System: Searching For Updates", Color.Orange)
Dim ServerVersion As String = XVersion
Dim ClientVersion As String = Application.ProductVersion
If ServerVersion = ClientVersion Then
WriteLog("System: Server Version Is Equal Newer Local Version.", Color.Orange)
WriteLog("System: You Have The Current Updated Version Of The Application.", Color.Green)
ElseIf ServerVersion < ClientVersion Then
WriteLog("System: Server Version Is Not Newer Local Version.", Color.Orange)
WriteLog("System: You Application's Version Is Greater Then The One On The Server", Color.Green)
WriteLog("System: This Is Likely An Error Or Maybe You Are Some Sort Of Super Admin God Or Something.", Color.RoyalBlue)
WriteLog("System: This Error Is From One Of The file Version On The Application Being To High Or The Version On The Server Being To Low.", Color.RoyalBlue)
WriteLog("System: Obviously You Are Not Meant To See This Very Silly Error, Could You Please Email The Developer At: EMAIL@ADDRESS.net.au", Color.RoyalBlue)
ElseIf ServerVersion > ClientVersion Then
WriteLog("System: Server Version Is Newer Local Version.", Color.Orange)
Try
WriteLog("System: Downloading Newer Version.", Color.Orange)
Process.Start(XLocation)
WriteLog("System: Download Complete.", Color.Green)
Catch ex As Exception
WriteLog("System: Could Not Download Update, Error: " & ex.Message, Color.Red)
End Try
End If
Catch ex As Exception
WriteLog("System: Could Not Complete Updates, Error: " & ex.Message, Color.Red)
End Try
End If
End Sub
#End If
#End Region 'Region_Updater1
Yeah, I made this in my lunch break
What the code will do is download the Update.xml file of the web.
Read the download dile location "Update_Location1" then download it (i will mod this as it could me used is a bad way)
And the Update.xml file
="1.0"="utf-8"="yes"
<Table>
<Update>
<Update_id>1</Update_id>
<Update_Version>1.0.23.1</Update_Version>
<Update_Location1>http://localhost/sites/update/application/files/1.0.0.23/test.zip</Update_Location1>
<Update_LocalPath>\Update.xml</Update_LocalPath>
</Update>
</Table>
Is this the right way of reading and writing the xml file?
Can i read / write to XML files on my site, or do i need to download read / write then upload via FTP?
I will upload the sorce code from the testing application after i have everything working.
Thanks for reading all of that.