escape characters in *.settings file

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
 
P

Peter Duniho

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
 
S

sklett

Hi Peter,

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

Take care,
Steve
 

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