Jon Winterburn
asked on
Loop through AppSettings in VB.NET app.config
Hi experts,
I have a number of settings in app.config which I wish to loop through and read their values into my Windows Service. However, I am unable to get this to work - what am I doing wrong?
Thanks
Jon
I have a number of settings in app.config which I wish to loop through and read their values into my Windows Service. However, I am unable to get this to work - what am I doing wrong?
Thanks
Jon
Protected Overrides Sub OnStart(ByVal args() As String)
For Each sp As Configuration.SettingsPropertyValue In My.Settings.Properties
myWatch = New System.IO.FileSystemWatcher(strServer & sp.ToString, "*.*")
AddHandler myWatch.Created, AddressOf Me.RunMySub
myWatch.IncludeSubdirectories = False
myWatch.EnableRaisingEvents = True
Next
End Sub
<applicationSettings>
<MyApp.My.MySettings>
<setting name="Path01" serializeAs="String">
<value>The value I want number 1</value>
</setting>
<setting name="Path02" serializeAs="String">
<value>The value I want number 2</value>
</setting>
<setting name="Path03" serializeAs="String">
<value>The value I want number 3</value>
</setting>
</MyApp.My.MySettings>
</applicationSettings>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent, thanks! I knew I was close.
NP. Glad to help = )
Open in new window