Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...with companys cutting back on training, lack of true support by makers of software, the forums are a great tool in your cyber-toolbox...."

Geography

Where in the world do Tek-Tips members come from?
lidds (Programmer)
21 May 12 6:42
I have a file called setting.xml which contains the following:

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
jebenson (TechnicalUser)
21 May 12 9:48
Since this is an XML file, use the XML objects in .NET to read it:


Dim XMLDoc As XmlDocument

Dim SettingsList As XmlNodeList

Dim SettingsNode As XmlNode

Dim customerLicCode As String = ""

XMLDoc = New XmlDocument

XMLDoc.Load("%AppDomainAppPath%App_Data\settings.xml")

SettingsList = XMLDoc.SelectNodes("/settings")

SettingsNode = SettingsList(0) 'I'm not too sure about this index, you might need to change this line a bit

customerLicCode = SettingsNode.Attributes("customerDeploymentLicenseCode").Value

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close