I have a file called setting.xml which contains the following:
What I am trying to do is return the information for the "customerDeploymentLicenseCode" line e.g. dgAAAJEL0iTaEM0BkLI9HW00
I have done the following code, but for some reason it is not matching/finding that line and therefore returns nothing. I can't seem to figure out why not, is it possible for someon to point out my mistake?
Thanks
Simon
Code:
<?xml version="1.0" encoding="utf-8"?>
<settings
licenseServiceType="1"
protectedStorageFile="%AppDomainAppPath%App_Data\storage.psf"
addressSigned="tgAAAIv1/CTaEM0BkLI9HW0ozQEZAGh0dHA6Ly8xMC4xMjguNTQuNDk6ODA5MS96FnzeHrzBS3YydgZ/nSOa8zEGLKNhas0PomOdV/JBhBP9HLq09G6MUb6uwoJ4ogQ="
customerDeploymentLicenseCode="dgAAAJEL0iTaEM0BkLI9HW00"
>
</settings>
What I am trying to do is return the information for the "customerDeploymentLicenseCode" line e.g. dgAAAJEL0iTaEM0BkLI9HW00
I have done the following code, but for some reason it is not matching/finding that line and therefore returns nothing. I can't seem to figure out why not, is it possible for someon to point out my mistake?
Code:
Public Function GetServerLicenseCode() As String
Dim settingsFilePath As String = GetRealFilePath("%AppDomainAppPath%App_Data\settings.xml")
Dim objFileName As FileStream = New FileStream(settingsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim objFileRead As StreamReader = New StreamReader(objFileName)
Dim customerLicCode As String = ""
Do While (objFileRead.Peek() > -1)
If objFileRead.ReadLine().IndexOf("customerDeploymentLicenseCode") <> -1 Then
' customerLicCode = objFileRead.ReadLine().Replace("customerDeploymentLicenseCode=", "")
customerLicCode = objFileRead.ReadLine()
Exit Do
End If
Loop
Return customerLicCode
End Function
Thanks
Simon