ConfigurationException with character '&'

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

app.config :

<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="FileContent" value="\IM\=W~!@#$%^*()_+|\/eb&\ErrorLog\" />
</appSettings>
</configuration>

code:
string content = ConfigurationSettings.AppSettings["FileContent"]

when the program run, ConfigurationException happened.if i replace character
'&', everthing is ok.

help me.
thanks in advance.
 
Peter said:
app.config :

<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="FileContent" value="\IM\=W~!@#$%^*()_+|\/eb&\ErrorLog\" />
</appSettings>
</configuration>

code:
string content = ConfigurationSettings.AppSettings["FileContent"]

when the program run, ConfigurationException happened.if i replace
character
'&', everthing is ok.

Try replacing '&' with '&amp;', i.e.

<add key="FileContent" value="\IM\=W~!@#$%^*()_+|\/eb&amp;\ErrorLog\" />

/Jens
 
Back
Top