Question: Getting app settings?

  • Thread starter Thread starter VB Programmer
  • Start date Start date
V

VB Programmer

I suppose it's XML, but is there a way to easily parse/read app settings?

In ASP.NET I can use the '<appSettings>' section in the Web.config (by
calling the ConfigurationSettings.AppSettings method.) I would like to find
another similar way to do it in VB.NET.

Thanks.
 
'xml file for user choice of connection
<?xml version="1.0" encoding="utf-8" ?>
<Section Name="Settings">
<Key Name="databasepath" Value="C:\database.mdb"/>
</Section>

Loading the file at startup of app....

Private Sub ReadXmlConfig()
' Create Xml Document and load the xml file
Dim xmlDoc As XmlDocument = New XmlDocument
xmlDoc.Load("C:\Neumann Plumbing and Heating\XMLDBPATH.xml") 'can
use appdirectory when finished with project.
' Read mail server value
Dim keyNodeList As XmlNodeList =
xmlDoc.DocumentElement.SelectNodes("Key")
Dim keyNode As XmlNode
For Each keyNode In keyNodeList
' Read the attributes...
Dim attribs As XmlAttributeCollection = keyNode.Attributes
Dim attrib As XmlAttribute = attribs("Name")
If attrib.Value = "databasepaths" Then
databasepath = attribs("Value").Value.ToString()
'MsgBox(databasepath)
End If
Next
End Sub
 
Thanks!

scorpion53061 said:
'xml file for user choice of connection
<?xml version="1.0" encoding="utf-8" ?>
<Section Name="Settings">
<Key Name="databasepath" Value="C:\database.mdb"/>
</Section>

Loading the file at startup of app....

Private Sub ReadXmlConfig()
' Create Xml Document and load the xml file
Dim xmlDoc As XmlDocument = New XmlDocument
xmlDoc.Load("C:\Neumann Plumbing and Heating\XMLDBPATH.xml") 'can
use appdirectory when finished with project.
' Read mail server value
Dim keyNodeList As XmlNodeList =
xmlDoc.DocumentElement.SelectNodes("Key")
Dim keyNode As XmlNode
For Each keyNode In keyNodeList
' Read the attributes...
Dim attribs As XmlAttributeCollection = keyNode.Attributes
Dim attrib As XmlAttribute = attribs("Name")
If attrib.Value = "databasepaths" Then
databasepath = attribs("Value").Value.ToString()
'MsgBox(databasepath)
End If
Next
End Sub
 
Back
Top