escape characters in *.settings file

  • Thread starter Thread starter sklett
  • Start date Start date
S

sklett

I'm having some trouble storing a string in my settings file that contains
escape characters.
If I enter "This is the first line\r\nand this is the second line."

When I retrieve the string from the settings file I get: "This is the first
line\\r\\nand this is the second line."
It seems to think it's a path or something?

Anyone else dealt with this before? I googled the problem but didn't find
anything (so far).

Thanks for any help,
Steve
 
sklett said:
I'm having some trouble storing a string in my settings file that contains
escape characters.
If I enter "This is the first line\r\nand this is the second line."

When I retrieve the string from the settings file I get: "This is the first
line\\r\\nand this is the second line."
It seems to think it's a path or something?

It's not that it thinks it's a path. It's that you have entered a
backslash in your text in the file, and so when you look at the string
in the debugger, the debugger escapes the backslash so that it's clear
that you're looking at a backslash character rather than something else.

I admit, it can actually wind up more confusing rather than less if
you're not used to it. :) But that's the intent anyway.

Now, as for the actual problem, I'm not actually sure what settings file
you're talking about, but if you want to escape characters you're going
to have to go through and convert those escaped characters to what they
represent. For example, string.Replace() where you replace the string
"\\r\\n" with Environment.NewLine.

Pete
 
Hi Peter,

Thanks for the reply. I will use the Replace() method to make everything
work.

Take care,
Steve
 
Back
Top