ConfigurationException with character '&'

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.
 
J

Jens Christian Mikkelsen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top