views:

455

answers:

2

Here's the line from App.Config:

<add key="CheckFileFormatString" value="P{0}\t&quot;{1}, {2}&quot;\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}"/>

Here's the code that puts it into a string (please ignore the deprecated .AppSettings.Get call, unless that's the problem):

string format = ConfigurationSettings.AppSettings.Get("CheckFileFormatString");

...and here's the resulting string:

P{0}\\t\"{1}, {2}\"\\t{3}\\t{4}\\t{5}\\t{6}\\t{7}\\t{8}\\t{9}\\t{10}

Where's the extra backslash coming from?

+2  A: 

\t is the symbol for a tab in C# etc, but this is not the case in XML. Your \t is being interpreted as two characters. Try replacing \t with &#09; in your config file.

Richard
A: 

The extra backslash comes from how the debugger displays the value.

The string value is displaed just as how you would write it as a string literal in the code, so each backslash in the string is displayed as \.

The backslashes in your string comes from the XML value, as backslashes is not an escape character in XML. As Richard explained, you need to use ` ' to get a tab character in the XML value.

Guffa