OK - I have an App.config file and am able to read single items in name/value pairs thus:
which is accessed by:Code:<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <!-- Monitor level...1=Max, 2=Min, 3=None--> <add key="MonitorJobEventInformationLevel" value="1"/> <!-- Monitor Printer Change Events? 0=No, -1 = Yes --> <add key="MonitorPrinterChangeEvent" value="-1"/> <!-- Monitor Job Added Events? 0=No, -1 = Yes --> <add key="MonitorJobAddedEvent" value="-1"/> <!-- Monitor Job Deleted Events? 0=No, -1 = Yes --> <add key="MonitorDeletedEvent" value="-1"/> <!-- Monitor Job Set Events? 0=No, -1 = Yes --> <add key="MonitorJobSetEvent" value="-1"/> <!-- Monitor Job Written Events? 0=No, -1 = Yes --> <add key="MonitorJobWrittenEvent" value="-1"/> </appSettings> </configuration>
VB Code:
Dim foo As Integer = System.Configuration.AppSettings.GetSetting("MonitorJobEventInformationLevel")
But I also have a collection (of printer names, for example) and I want to store and access this in the config file. How can this be done?
Currently I have a workaround which is:
but I would prefer a more XML approach e.g.:Code:<add key="MonitoredPrintersCount" value="2"/> <add key="MonitoredPrinter1" value="HP LaserJet 5L"/> <add key="MonitoredPrinter2" value="Microsoft Office Document Image Writer"/>
Thanks in advance,Code:<monitoredprinters> <add DeviceName="HP LaserJet 5L"/> <add DeviceName="Microsoft Office Document Image Writer"/> </monitoredprinters>
Duncan


Reply With Quote